[lkml]   [2011]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [patch 7/8] mm: memcg: modify PageCgroupAcctLRU non-atomically
    On Wed, Nov 23, 2011 at 10:52:39AM -0800, Hugh Dickins wrote:
    > On Wed, 23 Nov 2011, Johannes Weiner wrote:
    > > From: Johannes Weiner <>
    > >
    > > This bit is protected by zone->lru_lock, there is no need for locked
    > > operations when setting and clearing it.
    > >
    > > Signed-off-by: Johannes Weiner <>
    > Unless there are special considerations which you have not mentioned at
    > all in the description above, this 7/8 and the similar 8/8 are mistaken.
    > The atomic operation is not for guaranteeing the setting and clearing
    > of the bit in question: it's for guaranteeing that you don't accidentally
    > set or clear any of the other bits in the same word when you're doing so,
    > if another task is updating them at the same time as you're doing this.
    > There are circumstances when non-atomic shortcuts can be taken, when
    > you're sure the field cannot yet be visible to other tasks (we do that
    > when setting PageLocked on a freshly allocated page, for example - but
    > even then have to rely on others using get_page_unless_zero properly).
    > But I don't think that's the case here.

    I have no idea how I could oversee this. You are, of course, right.

    That said, I *think* that it is safe for PageCgroupCache because
    nobody else should be modifying any pc->flags concurrently:

    PCG_LOCK: by definition exclusive and held during setting and clearing

    PCG_CACHE: serialized by PCG_LOCK

    PCG_USED: serialized by PCG_LOCK

    PCG_MIGRATION: serialized by PCG_LOCK

    PCG_MOVE_LOCK: 1. update_page_stat() is only called against file
    pages, and the page lock serializes charging against mapping. the
    page is also charged before establishing a pte mapping, so an unmap
    can not race with a charge. 2. split_huge_fixup runs against already
    charged pages. 3. move_account is serialized both by LRU-isolation
    during charging and PCG_LOCK


    PCG_ACCT_LRU: pages are isolated from the LRU during charging

    But all this is obviously anything but robust, and so I retract the
    broken 7/8 and the might-actually-work 8/8.

     \ /
      Last update: 2011-11-24 09:57    [W:0.020 / U:34.144 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site