Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp653294pxk; Thu, 1 Oct 2020 10:32:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGOYKKmn8PDzAJrMlBS1dwZCKa8Y1gUYTtnVRsOttEFCNkkU3DAfH2KHY9dLNmggB42tRQ X-Received: by 2002:a17:906:bcfc:: with SMTP id op28mr9558141ejb.248.1601573546194; Thu, 01 Oct 2020 10:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601573546; cv=none; d=google.com; s=arc-20160816; b=zunYRZgiDfKZsYONtwQ9if7r1UEeI9KnoBcg7PJz+V0/kii2sW+k705xOpG8kiYUnL RHtwFeItQ90VNvHpfzYKz7sRptlDQ2t5nNpD8bMniwFJxAPFIecqO8ACdMFnqrvC/4eL aPZOeCH3cSKybh5QyV4I5lcVvLalg3sD1iHPeRpbPCTRyzuDbSoISoWQZNHJTGWQlHIO q8XRwbyDVQkHxumGYrJFcChOxN+nBOUZpR9hIsSnOLN4a+BaBku/Dl6T8JUwtM4zA0Vf 5wQKTaXyuClqYFshEAE1y8SLz3IiUUFZ71Kx/8xVwV6096YUvNbmfKIGZElP/6a0pj3e MPGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cTvaI1eVY2OnmFQ3ki6lTkVmY7EWHdYKiZzBjOwmf/A=; b=TGrO9S0TBFqLMpfOGCOfFYPTQziaQgV9UgAb/7LnqArVlBG9eeWNHBM0ddAR6kEcFE +IVdsqeTz98wLJ7Z6ddAGHlkfdFP/rzYn8cr6YOcH323R0K/GuMmSvQSbjF2jwhz49M2 m4s180rIjwpYsoWtb8Fv2AfecYMNMZ7Cv85zYG4wxgdJ302oLm1msS8EkdIx4SVeXmPJ XJPjzH/YKyamUzvY7P4sF5uU88tudF6sDtx+pHwKAOqrDQyTi5hZN/e7LGMRDQoJbXiB y4xeAtPO/oUaOqcmTgAVfoUDnJGNI0Fxv8tdb2rJldvo9gcNme41AxzdhiqPvY491177 vtdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Ifiyw27k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si4606077ejz.700.2020.10.01.10.32.02; Thu, 01 Oct 2020 10:32:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Ifiyw27k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732791AbgJAR24 (ORCPT + 99 others); Thu, 1 Oct 2020 13:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732096AbgJAR24 (ORCPT ); Thu, 1 Oct 2020 13:28:56 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28A11C0613D0 for ; Thu, 1 Oct 2020 10:28:56 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id q63so6260357qkf.3 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=SlLUvdIdn2+mbNR0AIGYYZ1ji20DyCLQX3Z2zkG2VeLwKn6Va474tvsca9+1EU0kyV W2rjSGqrovlEtphhNF1oRjeimr//fYL0cgS6jyF8VS5n4I9tk9ORsNUjFcRH6h651ecj H7AWFEUBx7zRFrPb4J5ZXvQHS6SAzhxTiq9zn0rXKIjTJrGqV0+/hcih+zUWUoq/xnjb OS12X8G7cmiBWiXcneLhiVb2fMv8WXbtXj/XAR/HJgs8+fIn8UE1xTkf0ndusbZZ+O4O Q4Ls6MU7y/XOvsFbuzB8ehYDtZLik9LzAV3najM4DYu0Rq/ekK7r+uLGL3SK8Qj3V72R svSA== X-Gm-Message-State: AOAM531tQw1Z/urTOiNUJqdwRWK073SPAXwaQdOtCkILz7fnWiOmgeC3 eN4qTKqFQbg1bf7tgugNB3hZlA== 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 Content-Transfer-Encoding: 8bit In-Reply-To: <20201001170036.GA29848@blackbook> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 01, 2020 at 07:00:36PM +0200, Michal Koutn? wrote: > Hi. > > 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 = 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.