PA: Replace FreeWithSize() with Free() with FreeFlags::kWithSizeHint. [chromium/src : main]

1 view
Skip to first unread message

Takashi Sakamoto (Gerrit)

unread,
May 13, 2026, 1:25:50 AMMay 13
to Keishi Hattori, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
Attention needed from Keishi Hattori

Takashi Sakamoto added 1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Takashi Sakamoto . resolved

Would you review this CL?

Open in Gerrit

Related details

Attention is currently required from:
  • Keishi Hattori
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
Gerrit-Change-Number: 7829127
Gerrit-PatchSet: 6
Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-Attention: Keishi Hattori <kei...@chromium.org>
Gerrit-Comment-Date: Wed, 13 May 2026 05:25:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Takashi Sakamoto (Gerrit)

unread,
May 13, 2026, 1:26:37 AMMay 13
to Keishi Hattori, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
Attention needed from Keishi Hattori

Takashi Sakamoto added 1 comment

File base/allocator/partition_allocator/src/partition_alloc/partition_root.h
Line 246, Patchset 6 (Latest): uint32_t type_id = 0;
Takashi Sakamoto . unresolved

I think this will be replaced with alloc_token (or add new member for alloc_token).

Open in Gerrit

Related details

Attention is currently required from:
  • Keishi Hattori
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
    Gerrit-Change-Number: 7829127
    Gerrit-PatchSet: 6
    Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
    Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
    Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-Attention: Keishi Hattori <kei...@chromium.org>
    Gerrit-Comment-Date: Wed, 13 May 2026 05:26:33 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stephen Nusko (Gerrit)

    unread,
    May 14, 2026, 12:49:02 AMMay 14
    to Takashi Sakamoto, Keishi Hattori, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
    Attention needed from Keishi Hattori and Takashi Sakamoto

    Stephen Nusko added 4 comments

    File base/allocator/partition_allocator/src/partition_alloc/partition_root.h
    Line 1462, Patchset 6 (Latest): new_hint.size = adjusted_size;
    Stephen Nusko . unresolved

    This is what I mean by we could adjust it if it was taken by value?

    Line 1461, Patchset 6 (Latest): FreeHint new_hint = hint;
    Stephen Nusko . unresolved

    If we took the hint by value, rather than by const ref we could just update the one field that changed?

    Line 586, Patchset 6 (Latest): PA_NOINLINE void Free(void* object, const FreeHint& hint) {
    Stephen Nusko . unresolved

    Is it better to take these as value rather than const ref?

    It is quite a simple struct and then we could modify it for example when we adjust the size?

    File base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
    Line 540, Patchset 6 (Latest): partition_alloc::FreeHint hint;
    hint.size = size;
    Stephen Nusko . unresolved

    I think we can improve the readability a bit with either helper functions or initialier.

    some helper functions would look like this?

    `partition_alloc::FreeHint::Size(size)` -> returns a FreeHint with size set
    `partition_alloc::FreeHint::Alignment(alignment)` -> returns a FreeHint alignment set.
    `partition_alloc::FreeHint::SizeAndAlignment(size, alignment)` -> returns with both set.

    Since we do this frequently might make it read a bit better everywhere? And since there isn't that many combos it shouldn't be that bad.

    Bonus we could even have it cache the FreeFlags that it has.

    I.E. FreeHint::Size would set a field `const kFlags = FreeFlags::kWithSizeHint`

    And then we would just do
    `FreeInlineInUnknownRoot<base_free_flags | hint.flags>(object, hint);`

    The other suggestion would be to use initializers

    ```c++
    partition_alloc::FreeHint hint{
    .size = size,
    };
    ```
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Keishi Hattori
    • Takashi Sakamoto
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
    Gerrit-Change-Number: 7829127
    Gerrit-PatchSet: 6
    Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
    Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
    Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Takashi Sakamoto <ta...@google.com>
    Gerrit-Attention: Keishi Hattori <kei...@chromium.org>
    Gerrit-Comment-Date: Thu, 14 May 2026 04:48:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Keishi Hattori (Gerrit)

    unread,
    May 15, 2026, 1:24:18 AMMay 15
    to Takashi Sakamoto, Stephen Nusko, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
    Attention needed from Takashi Sakamoto

    Keishi Hattori added 3 comments

    File base/allocator/partition_allocator/src/partition_alloc/partition_alloc_unittest.cc
    Line 364, Patchset 6 (Latest): ptr);
    Keishi Hattori . unresolved

    Did you forget to pass in |hint|?

    File base/allocator/partition_allocator/src/partition_alloc/partition_root.h
    Line 1471, Patchset 6 (Latest): PA_PREFETCH(slot_span);
    Keishi Hattori . unresolved

    Don't we need to prefetch if settings_.enable_free_with_size is false?

    Line 1437, Patchset 6 (Latest):PA_ALWAYS_INLINE void PartitionRoot::FreeInline(void* object,
    Keishi Hattori . unresolved

    If kWithAlignmentHint is set don't we always require kWithSizeHint to be set? If so maybe we can have a static assert for that.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Takashi Sakamoto
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
    Gerrit-Change-Number: 7829127
    Gerrit-PatchSet: 6
    Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
    Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
    Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Takashi Sakamoto <ta...@google.com>
    Gerrit-Comment-Date: Fri, 15 May 2026 05:23:53 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Takashi Sakamoto (Gerrit)

    unread,
    May 21, 2026, 11:15:55 PM (14 days ago) May 21
    to Mikihito Matsuura, Stephen Nusko, Keishi Hattori, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
    Attention needed from Keishi Hattori and Stephen Nusko

    Takashi Sakamoto added 9 comments

    Patchset-level comments
    File-level comment, Patchset 13 (Latest):
    Takashi Sakamoto . resolved

    Thank you for the review.

    File base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h
    Line 79, Patchset 12: kMaxValue = kIntendedLeak,
    Takashi Sakamoto . unresolved

    I'm not sure whether `internal`-s should be alreays the last ones in the `FreeFlags` enum or not.

    File base/allocator/partition_allocator/src/partition_alloc/partition_alloc_unittest.cc
    Line 364, Patchset 6: ptr);
    Keishi Hattori . resolved

    Did you forget to pass in |hint|?

    Takashi Sakamoto

    Done

    File base/allocator/partition_allocator/src/partition_alloc/partition_root.h
    Line 1471, Patchset 6: PA_PREFETCH(slot_span);
    Keishi Hattori . unresolved

    Don't we need to prefetch if settings_.enable_free_with_size is false?

    Takashi Sakamoto

    The original `FreeInline<flags>(void* object)` doesn't check `settings_.enable_free_with_size`, c.f.

    ```
    template <FreeFlags flags>
    PA_ALWAYS_INLINE void PartitionRoot::FreeInline(void* object) {
    // The correct PartitionRoot might not be deducible if the |object| originates
    // from an override hook.
    bool early_return = FreeProlog<flags>(object, this);
    if (early_return) {
    return;
    }
    // FreeProlog ensures the object is not nullptr.
    PA_DCHECK(object);
      // Almost all calls to FreeNoNooks() will end up writing to |*object|.
    PA_PREFETCH_FOR_WRITE(object);
    auto [slot_start, slot_span] = GetSlotStartAndSlotSpanFromAddress(object);
    // We are going to read from |*slot_span| in all branches, but haven't
    // done it yet.
    PA_PREFETCH(slot_span);
    FreeNoHooksImmediate<flags>(slot_start, slot_span);
    }
    ```

    The `!ContainsFlags(flags, FreeFlags::kWithSizeHint)` means the original `FreeInline()` is invoked. Neither `FreeWithSizeInline()` nor `FreeWithSizeAlignmentInline()` is invoked.

    So since the original `FreeInline()` does not check `settings_.enable_free_with_size`, I think we can skip checking `settings_.enable_free_with_size` here.

    (If we call `FreeWithSizeInline()` or `FreeWithSizeAlignmentInline()`,

    ```
    template <FreeFlags flags>
    PA_ALWAYS_INLINE void PartitionRoot::FreeWithSizeInline(void* object,
    size_t size) {
    if (!settings_.enable_free_with_size) {
    FreeInline<flags>(object);
    return;
    }
    ... snip
    ```
    and
    ```
    template <FreeFlags flags>
    PA_ALWAYS_INLINE void PartitionRoot::FreeWithSizeAndAlignmentInline(
    void* object,
    size_t size,
    size_t alignment) {
    if (!settings_.enable_free_with_size) {
    FreeInline<flags>(object); // FreeInline()
    return;
    }
    ... snip
    ```
    we need to check `settings_.enable_free_with_size`.)
    Line 1462, Patchset 6: new_hint.size = adjusted_size;
    Stephen Nusko . resolved

    This is what I mean by we could adjust it if it was taken by value?

    Takashi Sakamoto

    Done

    Line 1461, Patchset 6: FreeHint new_hint = hint;
    Stephen Nusko . resolved

    If we took the hint by value, rather than by const ref we could just update the one field that changed?

    Takashi Sakamoto

    Done.
    I will check the binary (size and generated asm) when `FreeHintType` is much larger.

    Line 1437, Patchset 6:PA_ALWAYS_INLINE void PartitionRoot::FreeInline(void* object,
    Keishi Hattori . unresolved

    If kWithAlignmentHint is set don't we always require kWithSizeHint to be set? If so maybe we can have a static assert for that.

    Takashi Sakamoto

    Currently PartitionAlloc `AlignedFree` doesn't take `alignment`.

    So thinking about normal allocator, `AlignedFree` will take `alignment` argument and `FreeWithSize` will take `size` argument. `AlignedFreeWithSize` will take both.
    (The arguments don't depend on each other.)

    But because of PartitionAlloc impl, only `FreeWithSizeAndAlignment()` needs `alignment`.... I'm not sure whether we can say `alignment requires size` or not.

    To avoid mistakes, now `template struct FreeHint` captures such kind of `missing size` or `missing alignment`, because `FreeHint<FreeFlags::kWithAlignmentHint>::Type` has no `size` member (i.e. different type from `FreeHint<FreeFlags::kWithSizeHint>::Type`).

    Line 586, Patchset 6: PA_NOINLINE void Free(void* object, const FreeHint& hint) {
    Stephen Nusko . unresolved

    Is it better to take these as value rather than const ref?

    It is quite a simple struct and then we could modify it for example when we adjust the size?

    Takashi Sakamoto

    I made FreeHintType template struct and changed Free() to take values.

    Looking at binaries, using values instead of const ref seems to increase the size of binaries. (clang seems to optimize the binary to avoid lots of copies, but sometimes the code seems to need copies). But I found that always initializing unused struct members costs a lot...

    i.e.
    ```
    struct FreeHint {
    const char* type_name = nullptr;
    uint32_t type_id = 0;
    size_t size = 0;
    size_t alignment = 0;
    };
    FreeHint hint;
    hint.size = size;
    00000000004ad180 <partition_alloc::internal::(anonymous namespace)::PartitionAllocatorWithThreadCache::FreeWithSize(void*, unsigned long)>:
    4ad180: 55 push rbp
    4ad181: 48 89 e5 mov rbp, rsp
    4ad184: 48 83 ec 20 sub rsp, 0x20
    4ad188: 48 89 f7 mov rdi, rsi
    4ad18b: 48 b8 aa aa aa aa aa aa aa aa movabs rax, -0x5555555555555556
    4ad195: 48 89 45 e8 mov qword ptr [rbp - 0x18], rax
    4ad199: 48 c7 45 e0 00 00 00 00 mov qword ptr [rbp - 0x20], 0x0
    4ad1a1: c7 45 e8 00 00 00 00 mov dword ptr [rbp - 0x18], 0x0
    4ad1a8: 48 c7 45 f8 00 00 00 00 mov qword ptr [rbp - 0x8], 0x0
      4ad1b0: 48 89 55 f0                   mov     qword ptr [rbp - 0x10], rdx
    4ad1b4: 48 8d 75 e0 lea rsi, [rbp - 0x20]
    4ad1b8: e8 83 49 39 00 call 0x841b40 <void partition_alloc::PartitionRoot::FreeInUnknownRoot<(partition_alloc::internal::FreeFlags)18>(void*, partition_alloc::FreeHint const&)>
    4ad1bd: 48 83 c4 20 add rsp, 0x20
    4ad1c1: 5d pop rbp
    4ad1c2: c3 ret
    ```
    If we don't initialize the struct members,
    ```
    struct FreeHint {
    // Members are intentionally left uninitialized for performance
    // reason.
    // If using zero-initialization,
    // FreeHinit hint
    const char* type_name;
    uint32_t type_id;
    size_t size;
    size_t alignment;
    };

    FreeHint hint;
    hint.size = size;
    00000000004ad180 <partition_alloc::internal::(anonymous namespace)::PartitionAllocatorWithThreadCache::FreeWithSize(void*, unsigned long)>:
    4ad180: 55 push rbp
    4ad181: 48 89 e5 mov rbp, rsp
    4ad184: 48 83 ec 20 sub rsp, 0x20
    4ad188: 48 89 f7 mov rdi, rsi
    4ad18b: 0f 28 05 be 4d d2 ff movaps xmm0, xmmword ptr [rip - 0x2db242] # 0x1d1f50 <gPublicTypes+0x7c0>
    4ad192: 0f 29 45 f0 movaps xmmword ptr [rbp - 0x10], xmm0
    4ad196: 0f 29 45 e0 movaps xmmword ptr [rbp - 0x20], xmm0
      4ad19a: 48 89 55 f0                   mov     qword ptr [rbp - 0x10], rdx
    4ad19e: 48 8d 75 e0 lea rsi, [rbp - 0x20]
    4ad1a2: e8 79 49 39 00 call 0x841b20 <void partition_alloc::PartitionRoot::FreeInUnknownRoot<(partition_alloc::internal::FreeFlags)18>(void*, partition_alloc::FreeHint const&)>
    4ad1a7: 48 83 c4 20 add rsp, 0x20
    4ad1ab: 5d pop rbp
    4ad1ac: c3 ret
    ```
    So if the struct looks like:
    ```
    struct FreeHint {
    size_t size = 0;
    };
    00000000004ad540 <partition_alloc::internal::(anonymous namespace)::PartitionAllocatorWithThreadCache::FreeWithSize(void*, unsigned long)>:
    4ad540: 55 push rbp
    4ad541: 48 89 e5 mov rbp, rsp
    4ad544: 48 89 f7 mov rdi, rsi
    4ad547: 48 89 d6 mov rsi, rdx
    4ad54a: 5d pop rbp
    4ad54b: e9 10 61 39 00 jmp 0x843660 <void partition_alloc::PartitionRoot::FreeInUnknownRoot<(partition_alloc::internal::FreeFlags)18>(void*, partition_alloc::FreeHint<partition_alloc::internal::FreeFlags partition_alloc::internal::FreeHintFlags<partition_alloc::internal::FreeFlags>(partition_alloc::internal::FreeFlags)((partition_alloc::internal::FreeFlags)18)>::Type)>
    ```

    So now `Free<kWithSizeHint>(void*, FreeHint)` is almost the same as `FreeWithSize(void*, size_t)`.

    File base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
    Line 540, Patchset 6: partition_alloc::FreeHint hint;
    hint.size = size;
    Stephen Nusko . resolved

    I think we can improve the readability a bit with either helper functions or initialier.

    some helper functions would look like this?

    `partition_alloc::FreeHint::Size(size)` -> returns a FreeHint with size set
    `partition_alloc::FreeHint::Alignment(alignment)` -> returns a FreeHint alignment set.
    `partition_alloc::FreeHint::SizeAndAlignment(size, alignment)` -> returns with both set.

    Since we do this frequently might make it read a bit better everywhere? And since there isn't that many combos it shouldn't be that bad.

    Bonus we could even have it cache the FreeFlags that it has.

    I.E. FreeHint::Size would set a field `const kFlags = FreeFlags::kWithSizeHint`

    And then we would just do
    `FreeInlineInUnknownRoot<base_free_flags | hint.flags>(object, hint);`

    The other suggestion would be to use initializers

    ```c++
    partition_alloc::FreeHint hint{
    .size = size,
    };
    ```
    Takashi Sakamoto

    I see. Done.
    Now my concern is clang plugin: `complex class or struct`.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Keishi Hattori
    • Stephen Nusko
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
    Gerrit-Change-Number: 7829127
    Gerrit-PatchSet: 13
    Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
    Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
    Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Mikihito Matsuura <mi...@google.com>
    Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
    Gerrit-Attention: Keishi Hattori <kei...@chromium.org>
    Gerrit-Comment-Date: Fri, 22 May 2026 03:15:47 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
    Comment-In-Reply-To: Keishi Hattori <kei...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Keishi Hattori (Gerrit)

    unread,
    May 26, 2026, 3:25:46 AM (9 days ago) May 26
    to Takashi Sakamoto, Code Review Nudger, Mikihito Matsuura, Stephen Nusko, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
    Attention needed from Stephen Nusko and Takashi Sakamoto

    Keishi Hattori voted and added 1 comment

    Votes added by Keishi Hattori

    Code-Review+1

    1 comment

    Patchset-level comments
    File-level comment, Patchset 14 (Latest):
    Keishi Hattori . resolved

    LGTM

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Stephen Nusko
    • Takashi Sakamoto
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
      Gerrit-Change-Number: 7829127
      Gerrit-PatchSet: 14
      Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
      Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
      Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Mikihito Matsuura <mi...@google.com>
      Gerrit-CC: Stephen Nusko <nus...@chromium.org>
      Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
      Gerrit-Attention: Takashi Sakamoto <ta...@google.com>
      Gerrit-Comment-Date: Tue, 26 May 2026 07:25:24 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Takashi Sakamoto (Gerrit)

      unread,
      May 26, 2026, 8:47:04 PM (9 days ago) May 26
      to Keishi Hattori, Code Review Nudger, Mikihito Matsuura, Stephen Nusko, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
      Attention needed from Stephen Nusko

      Takashi Sakamoto added 6 comments

      Patchset-level comments
      Takashi Sakamoto . resolved

      Thank you for the review.

      File base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h
      Line 79, Patchset 12: kMaxValue = kIntendedLeak,
      Takashi Sakamoto . resolved

      I'm not sure whether `internal`-s should be alreays the last ones in the `FreeFlags` enum or not.

      Takashi Sakamoto

      Acknowledged

      File base/allocator/partition_allocator/src/partition_alloc/partition_root.h
      Line 1471, Patchset 6: PA_PREFETCH(slot_span);
      Keishi Hattori . resolved
      Takashi Sakamoto

      Acknowledged

      Line 1437, Patchset 6:PA_ALWAYS_INLINE void PartitionRoot::FreeInline(void* object,
      Keishi Hattori . resolved

      If kWithAlignmentHint is set don't we always require kWithSizeHint to be set? If so maybe we can have a static assert for that.

      Takashi Sakamoto

      Currently PartitionAlloc `AlignedFree` doesn't take `alignment`.

      So thinking about normal allocator, `AlignedFree` will take `alignment` argument and `FreeWithSize` will take `size` argument. `AlignedFreeWithSize` will take both.
      (The arguments don't depend on each other.)

      But because of PartitionAlloc impl, only `FreeWithSizeAndAlignment()` needs `alignment`.... I'm not sure whether we can say `alignment requires size` or not.

      To avoid mistakes, now `template struct FreeHint` captures such kind of `missing size` or `missing alignment`, because `FreeHint<FreeFlags::kWithAlignmentHint>::Type` has no `size` member (i.e. different type from `FreeHint<FreeFlags::kWithSizeHint>::Type`).

      Takashi Sakamoto

      Acknowledged

      Line 586, Patchset 6: PA_NOINLINE void Free(void* object, const FreeHint& hint) {
      Stephen Nusko . resolved
      Takashi Sakamoto

      Acknowledged

      Line 246, Patchset 6: uint32_t type_id = 0;
      Takashi Sakamoto . resolved

      I think this will be replaced with alloc_token (or add new member for alloc_token).

      Takashi Sakamoto

      Acknowledged

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Stephen Nusko
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
        Gerrit-Change-Number: 7829127
        Gerrit-PatchSet: 14
        Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
        Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
        Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Kentaro Hara <har...@chromium.org>
        Gerrit-CC: Mikihito Matsuura <mi...@google.com>
        Gerrit-CC: Stephen Nusko <nus...@chromium.org>
        Gerrit-Attention: Stephen Nusko <nus...@chromium.org>
        Gerrit-Comment-Date: Wed, 27 May 2026 00:46:53 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Stephen Nusko <nus...@chromium.org>
        Comment-In-Reply-To: Takashi Sakamoto <ta...@google.com>
        Comment-In-Reply-To: Keishi Hattori <kei...@chromium.org>
        satisfied_requirement
        open
        diffy

        Takashi Sakamoto (Gerrit)

        unread,
        May 26, 2026, 8:47:09 PM (9 days ago) May 26
        to Keishi Hattori, Code Review Nudger, Mikihito Matsuura, Stephen Nusko, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org
        Attention needed from Stephen Nusko

        Takashi Sakamoto voted Commit-Queue+2

        Commit-Queue+2
        Gerrit-Comment-Date: Wed, 27 May 2026 00:47:03 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        May 26, 2026, 10:05:39 PM (9 days ago) May 26
        to Takashi Sakamoto, Keishi Hattori, Code Review Nudger, Mikihito Matsuura, Stephen Nusko, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, Kentaro Hara, kinuko...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org, bartek...@chromium.org, lize...@chromium.org, lizeb...@chromium.org, wfh+...@chromium.org

        Chromium LUCI CQ submitted the change

        Change information

        Commit message:
        PA: Replace FreeWithSize() with Free() with FreeFlags::kWithSizeHint.

        Add template struct FreeHint to provide additional information at
        Free(), e.g. size. The template parameter is the same as PartitionRoot
        Free()'s, i.e. `template <FreeFlags flags> Free(void*,
        FreeHint<flags>::Type)`. If FreeFlags contains kWithSizeHint (constexpr
        ContainsFlags), FreeHint<kWithSizeHint|...>::Type will have size member
        and PartitionRoot::Free() can use its value (otherwise, no size member).
        This template struct helps us to avoid initializing and copying unused
        struct members.
        Bug: 501113274
        Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
        Reviewed-by: Keishi Hattori <kei...@chromium.org>
        Commit-Queue: Takashi Sakamoto <ta...@google.com>
        Cr-Commit-Position: refs/heads/main@{#1636645}
        Files:
        • M base/allocator/partition_allocator/src/partition_alloc/BUILD.gn
        • A base/allocator/partition_allocator/src/partition_alloc/free_hint.h
        • M base/allocator/partition_allocator/src/partition_alloc/internal/partition_root_exports.h
        • M base/allocator/partition_allocator/src/partition_alloc/internal/partition_root_internal.h
        • M base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h
        • M base/allocator/partition_allocator/src/partition_alloc/partition_alloc_perftest.cc
        • M base/allocator/partition_allocator/src/partition_alloc/partition_alloc_unittest.cc
        • M base/allocator/partition_allocator/src/partition_alloc/partition_root.cc
        • M base/allocator/partition_allocator/src/partition_alloc/partition_root.h
        • M base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
        • M third_party/blink/renderer/platform/wtf/allocator/partitions.cc
        Change size: L
        Delta: 11 files changed, 172 insertions(+), 120 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        • requirement satisfiedCode-Review: +1 by Keishi Hattori
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ic7869bb2203182b8c1de201d45c2097dc1b69783
        Gerrit-Change-Number: 7829127
        Gerrit-PatchSet: 15
        Gerrit-Owner: Takashi Sakamoto <ta...@google.com>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Keishi Hattori <kei...@chromium.org>
        Gerrit-Reviewer: Takashi Sakamoto <ta...@google.com>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages