From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4575C4741F for ; Thu, 1 Oct 2020 17:28:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2435A20897 for ; Thu, 1 Oct 2020 17:28:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="Ifiyw27k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2435A20897 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A712290000A; Thu, 1 Oct 2020 13:28:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FA23900003; Thu, 1 Oct 2020 13:28:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C38E90000A; Thu, 1 Oct 2020 13:28:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id 5B854900003 for ; Thu, 1 Oct 2020 13:28:57 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 025713628 for ; Thu, 1 Oct 2020 17:28:57 +0000 (UTC) X-FDA: 77324041914.22.cry89_1212ac92719d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id D14FD18038E67 for ; Thu, 1 Oct 2020 17:28:56 +0000 (UTC) X-HE-Tag: cry89_1212ac92719d X-Filterd-Recvd-Size: 4548 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 1 Oct 2020 17:28:56 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id x201so6246676qkb.11 for ; Thu, 01 Oct 2020 10:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=cTvaI1eVY2OnmFQ3ki6lTkVmY7EWHdYKiZzBjOwmf/A=; b=Ifiyw27kae41qtg0PObv6iwLOlFsSlh/I22uTxIBiFePtUZG77QvMVXvSLXSu46b7k Xk9QAwByiv2cwG33zWYbXdCXqIsxMyXSd04HJXKyvY44jEphpO8BcF5aWwRTrmj4B9lk kN9K9q5hYC08A9xBQmrKULBykNAl1njgO1Hl5pJdhtGU25e0RPFnhkzBU23nTGFC23ZC jk8YIVzMS28GVFcnSA7r6q8cSk/Jv+Z612HHu+ARlwnhjWCjGXymFNjb1omMdEyREAi/ TXtpfXi/4d8L6z6Ea9P+CSSCrxe3oa7R5rn8Tp5kw8/ZGX4ePKad8lLnLFNPw8oTsmWe eFSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=cTvaI1eVY2OnmFQ3ki6lTkVmY7EWHdYKiZzBjOwmf/A=; b=NTimBw5+PNGrvEJ+UrQY+O4u8vIxeWwOj9/LPRHB228s7wuOKuC61c0l/txItNs3gy ftTub/EQiJXcFcYhcWBLBUVcsSQpLTXSa7tbRweLuLjZHQCxJ0Q0phxGtDnMKqCuefrm L3AgHvdOcgHKAhOlrf4MFzPQfYf29A2gXqCu1YQSoMpe9cCbpyJT49Sijh4NAd4IkKAO DzVZ+FOUyK9CcnKa27Y7ARbAPb5Hgo7PZAZJHhCl6DkSdQ1C26exGFyq3btCVjIY5umt bUjALFT8LpPbLHyD3BeLt4KYHKUudFdg83fRDidrQ9TW12+NgxavtUogLENTbsAwN2sz oiAw== X-Gm-Message-State: AOAM530MjPtZcGiEVr773u2NcxJw9X5D2P5/URY2hUmYUjnnlNFx14pP EoJZL3qj2MwoEZ29cG1lqUMG5g== X-Google-Smtp-Source: ABdhPJxOL87QOYC8fbmvcToVHw7h3RdDxNazf3n7Us2F4dA657WGsRkzwapgpDTbyaOcfYeMlZm7kg== X-Received: by 2002:a37:ef14:: with SMTP id j20mr8885502qkk.101.1601573335441; Thu, 01 Oct 2020 10:28:55 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:4e22]) by smtp.gmail.com with ESMTPSA id 90sm3871205qtb.6.2020.10.01.10.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 10:28:54 -0700 (PDT) Date: Thu, 1 Oct 2020 13:27:13 -0400 From: Johannes Weiner To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: Roman Gushchin , Andrew Morton , Shakeel Butt , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: Re: [PATCH v4 4/4] mm: convert page kmemcg type to a page memcg flag Message-ID: <20201001172713.GA500308@cmpxchg.org> References: <20201001002710.748166-1-guro@fb.com> <20201001002710.748166-5-guro@fb.com> <20201001170036.GA29848@blackbook> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20201001170036.GA29848@blackbook> Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 01, 2020 at 07:00:36PM +0200, Michal Koutn=FD wrote: > Hi. >=20 > On Wed, Sep 30, 2020 at 05:27:10PM -0700, Roman Gushchin = wrote: > > @@ -369,8 +371,12 @@ enum page_memcg_data_flags { > > */ > > static inline struct mem_cgroup *page_memcg(struct page *page) > > { > > + unsigned long memcg_data =3D page->memcg_data; > > + > > VM_BUG_ON_PAGE(PageSlab(page), page); > > - return (struct mem_cgroup *)page->memcg_data; > > + VM_BUG_ON_PAGE(memcg_data & MEMCG_DATA_OBJCGS, page); > > + > > + return (struct mem_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); > > } > Shouldn't this change go also into page_memcg_rcu()? (I don't think the > current single user (workingset_activation() would pass a non-slab > kernel page but for consistency sake.) +1 > Alternatively, I'm thinking why (in its single use) is there > page_memcg_rcu() a separate function to page_memcg() (cross memcg page > migration?). It goes back to commit 55779ec759ccc3c12b917b3712a7716e1140c652. The activation code is the only path where page migration is not excluded. Because unlike with page state statistics, we don't really mind a race when counting an activation event. I do think there is a bug, though: mem_cgroup_move_account() should use WRITE_ONCE() on page->mem_cgroup.