Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3866629pxb; Mon, 8 Feb 2021 02:02:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWdFzxuFD/H4CwnUQ5QAvJhOTH3HcF+Jy/jq+39yCJOBeOySX5ntT4Ys9hmVNcJo05gtJl X-Received: by 2002:aa7:db16:: with SMTP id t22mr729277eds.301.1612778567129; Mon, 08 Feb 2021 02:02:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612778567; cv=none; d=google.com; s=arc-20160816; b=Q94TX8MPpr0PEOGZnfl7+z2fTUYfinXKx6lIevs6GimyH5v39ydcYVMuxrE+2aOEQc KDKrkj1c0oux1ql444wdae+FgWueDRfLzAzF2KOI3y4HNLGVtFx4JI5pIwzn/wADEPCz RbpwCMk724GBO3YQBYOVgm9Zaw48I8msQxLw0mI5deM1zQ0MOixbRoBAXLuq4oDrIb5m P9KBJIsfo45qbmzPELvf10AYZi5dfnRvHw1fuMSFLQ38EF5eGTxCmDGm3QQ4bHZURht9 IxBeyLS3e0JhUNduDP3uQAGjs9P90OKV4e9fGX2FYYO7zVbV0FkUDPErNtCx4A7hV+Wx keVw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DBsRDf6sKqoMXs8BxrjoloByzTHcZkFKh1qcJfej7kE=; b=qUtFXmfIoZklUDQR+nj1upQZurbysdD4N1lqfO7He9a80zEaSU2NLa4bf3tv360DLJ YatsjYtrgzTPWQDqh0/ZyOz0/CBuAoG213ffeEDtvDQ3OAJn9yKwC9x1p8Gc6F00vdOy F+Y82lxKFp5coMMJqDBZ5lSZYtVSsOdXB6H2ewAVrsU4o7b815reP/0Ynq22lKeQbEVZ GIYeQ/3vGlQNLoDgG8f5Irs+AT9fEZWSNhCvr0b1WR1c95D7JGUvdsHFCwSO3tAen1zM PHV5RBnAhqsjWPPsPe0IMkAw43QopJjfbHvhF1iCNAp8Cz3kVusWdcefLzmjS1vmHLzL Skhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=RxLdmpgI; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg13si13293764ejc.669.2021.02.08.02.02.23; Mon, 08 Feb 2021 02:02:47 -0800 (PST) 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=@suse.com header.s=susede1 header.b=RxLdmpgI; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229861AbhBHKAa (ORCPT + 99 others); Mon, 8 Feb 2021 05:00:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:35330 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbhBHJvS (ORCPT ); Mon, 8 Feb 2021 04:51:18 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1612777831; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DBsRDf6sKqoMXs8BxrjoloByzTHcZkFKh1qcJfej7kE=; b=RxLdmpgIP2mi8IiqRZ8SAFMocjqnRTOjFH2a8wzNNG3Zam8FkcECpEIB1U0+xH5owzyP7q S0kfhi3+LbYmQib6RH4JkfgEhk+vEl1tKs105T7c8HR6vUAB8vci4uGyHYxqjjLNg47t0d Nq8qNK2qyrr65vSyHTHMbjBYjVWP6Vo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A5A65AE56; Mon, 8 Feb 2021 09:50:31 +0000 (UTC) Date: Mon, 8 Feb 2021 10:50:29 +0100 From: Michal Hocko To: Johannes Weiner Cc: Muchun Song , Vladimir Davydov , Andrew Morton , Cgroups , Linux Memory Management List , LKML Subject: Re: [External] Re: [PATCH] mm: memcontrol: remove rcu_read_lock from get_mem_cgroup_from_page Message-ID: References: <20210205062719.74431-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 05-02-21 13:15:40, Johannes Weiner wrote: > On Fri, Feb 05, 2021 at 11:32:24AM +0100, Michal Hocko wrote: > > On Fri 05-02-21 17:14:30, Muchun Song wrote: > > > On Fri, Feb 5, 2021 at 4:36 PM Michal Hocko wrote: > > > > > > > > On Fri 05-02-21 14:27:19, Muchun Song wrote: > > > > > The get_mem_cgroup_from_page() is called under page lock, so the page > > > > > memcg cannot be changed under us. > > > > > > > > Where is the page lock enforced? > > > > > > Because it is called from alloc_page_buffers(). This path is under > > > page lock. > > > > I do not see any page lock enforecement there. There is not even a > > comment requiring that. Can we grow more users where this is not the > > case? There is no actual relation between alloc_page_buffers and > > get_mem_cgroup_from_page except that the former is the only _current_ > > existing user. I would be careful to dictate locking based solely on > > that. > > Since alloc_page_buffers() holds the page lock throughout the entire > time it uses the memcg, there is no actual reason for it to use RCU or > even acquire an additional reference on the css. We know it's pinned, > the charge pins it, and the page lock pins the charge. It can neither > move to a different cgroup nor be uncharged. > > So what do you say we switch alloc_page_buffers() to page_memcg()? > > And because that removes the last user of get_mem_cgroup_from_page(), > we can kill it off and worry about a good interface once a consumer > materializes for it. Yes, this makes much more sense than impose a weird locking rules to a more general purpose helper. Thanks! -- Michal Hocko SUSE Labs