Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3637433ybb; Tue, 31 Mar 2020 09:04:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuSl70PV7COieRE0CsOmSqPmZ17XOJqjvyE4msS6MMLXpuh0XzzKl/PAmdp92hFciejdF02 X-Received: by 2002:a9d:6ad8:: with SMTP id m24mr3762994otq.66.1585670684147; Tue, 31 Mar 2020 09:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585670684; cv=none; d=google.com; s=arc-20160816; b=SpA4/+cWeRU6ScWCHasfM7A5fEtM0QyZKbHXEE3bLMsUs2gWXBMFhHYXuJ8C1bPu3M M8ESgBOM195NOFeMCvGaSLwrJShUEfeUJ/SJHsJBQaSfL/8swiqeRtzs2c6wVO60w6WG JTSbtCbuZqBiRt7OjxZoSi4al1JlkirLkyGj3wQxmlr9x0n56th5Acxwh3iXrw8O/NYR zjkL1TIA8vAJ1u2WU23KAOKSOi/1Ayw1Czio0frg7cVlObZmYQCUVur2P52prbO/FsC+ zJ1c42r0MCDBYLxyw8SaOmg1i+MKWGaBXz0/QAZHfdRmgNfWUOjGtPIUBpW7euRs0chc WGZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KUXmLIQ+aLx+dsd2X6HDAS3m5DJ2KKoj8xObBaVjK4k=; b=eRyIalYNw550MijahWYN/2iakkka2dL1WowvHA8Tm7uyejCB1LEKKpwtZV2WQC1xVQ 9v6pHQeC3haGHgmMO631T+1J1Qi+GZKDm9zt6iOziINFx+mwf6Ys6UFxPyyMWg+ktsj1 XFXIld3Mkc16BKBvGnHojYMNWwrsbriSm6lKg99Bu1xS2c1T4mMmSPGezq+yb2Mr7v4w jkTS/ACPJKT13UTHB70q4dOSb8K8vVY7Y2Cg/IrSW1NLdHW+Io1or9LIN69BoykmJ/xu 5aeQkILdIvWPMJc3nmRdC6GE88ENF6IcksmY2/3PQZ4Is6oDkyKfU9X0N4E1UvJ9ebcc 6isQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=iTuWUT6v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si6796401oie.6.2020.03.31.09.04.09; Tue, 31 Mar 2020 09:04:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=iTuWUT6v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731160AbgCaQBT (ORCPT + 99 others); Tue, 31 Mar 2020 12:01:19 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:35373 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730845AbgCaQBT (ORCPT ); Tue, 31 Mar 2020 12:01:19 -0400 Received: by mail-qk1-f196.google.com with SMTP id k13so23565910qki.2 for ; Tue, 31 Mar 2020 09:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KUXmLIQ+aLx+dsd2X6HDAS3m5DJ2KKoj8xObBaVjK4k=; b=iTuWUT6v6SPVuXPY9PvsAXbyhjYvsl0LYe57OruuLwH4ntWsnzYQJa0fyxayYlq8hB sbrLQW99kG1zDFcfBUsesq/nKvY3XcbTSh74JL27Fas3ze+KrwEBFFKob958qMMnSgkC jYoxFLqxXoBLeYzwZ2UMAsxNjVMZ+k4Ak8d8g= 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:in-reply-to:user-agent; bh=KUXmLIQ+aLx+dsd2X6HDAS3m5DJ2KKoj8xObBaVjK4k=; b=VwlpK+wK/k1aIwwn4iHUe/5APGjNirMg85SJNvh1gT6wkAdgwM1kj5dFWF/6LWcdz3 NTkdRknTCXGIUe8yrsxOldmcP8sIVEYuFLbXVMuyQQe2JmarC/X79DeMcwBXtW8NyI7v oJu1SBbFrOVhmjH3fa12worsfn6pAIu3ShtxISY51zKZMGw3jtZglIFDcdFmlv11V65P 9fBNCszB5YMPfCpOLTtnYp6hZtxC8nfsrwR9ikKH+xnsVpr5tc6yLBPBk1V7FuMdo0ZS iQA1m4KDJsBey6XD1Jp4VlAlpzP7hdwUloPHvC7uSGs8RBIr1JeTCCQ2Sw8Ny6Y7rYiH 9xPQ== X-Gm-Message-State: AGi0PuY1p6C7vJs79WCzdZgvswdsa/mAn+V2U54053brWfrXRCiqBAe5 XHYaKyaNRvsWmneoMZhaVcRPpg== X-Received: by 2002:a37:a88e:: with SMTP id r136mr269788qke.12.1585670478283; Tue, 31 Mar 2020 09:01:18 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id b145sm12861514qkg.52.2020.03.31.09.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 09:01:17 -0700 (PDT) Date: Tue, 31 Mar 2020 12:01:17 -0400 From: Joel Fernandes To: Michal Hocko Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, rcu@vger.kernel.org, willy@infradead.org, peterz@infradead.org, neilb@suse.com, vbabka@suse.cz, mgorman@suse.de, Andrew Morton , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , Steven Rostedt Subject: Re: [PATCH RFC] rcu/tree: Use GFP_MEMALLOC for alloc memory to free memory pattern Message-ID: <20200331160117.GA170994@google.com> References: <20200331131628.153118-1-joel@joelfernandes.org> <20200331145806.GB236678@google.com> <20200331153450.GM30449@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200331153450.GM30449@dhcp22.suse.cz> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 31, 2020 at 05:34:50PM +0200, Michal Hocko wrote: > On Tue 31-03-20 10:58:06, Joel Fernandes wrote: > [...] > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index 4be763355c9fb..965deefffdd58 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -3149,7 +3149,7 @@ static inline struct rcu_head *attach_rcu_head_to_object(void *obj) > > > > > > if (!ptr) > > > ptr = kmalloc(sizeof(unsigned long *) + > > > - sizeof(struct rcu_head), GFP_ATOMIC | __GFP_NOWARN); > > > + sizeof(struct rcu_head), GFP_MEMALLOC); > > > > Just to add, the main requirements here are: > > 1. Allocation should be bounded in time. > > 2. Allocation should try hard (possibly tapping into reserves) > > 3. Sleeping is Ok but should not affect the time bound. > > > __GFP_ATOMIC | __GFP_HIGH is the way to get an additional access to > memory reserves regarless of the sleeping status. > > Using __GFP_MEMALLOC is quite dangerous because it can deplete _all_ the > memory. What does prevent the above code path to do that? Can you suggest what prevents other users of GFP_MEMALLOC from doing that also? That's the whole point of having a reserve, in normal usage no one will use it, but some times you need to use it. Keep in mind this is not a common case in this code here, this is triggered only if earlier allocation attempts failed. Only *then* we try with GFP_MEMALLOC with promises to free additional memory soon. > If a partial access to reserves is sufficient then why the existing > modifiers (mentioned above are not sufficient? The point with using GFP_MEMALLOC is it is useful for situations where you are about to free memory and needed some memory temporarily, to free that. It depletes it a bit temporarily to free even more. Is that not the point of PF_MEMALLOC? * %__GFP_MEMALLOC allows access to all memory. This should only be used when * the caller guarantees the allocation will allow more memory to be freed * very shortly e.g. process exiting or swapping. Users either should * be the MM or co-ordinating closely with the VM (e.g. swap over NFS). I was just recommending usage of this flag here because it fits the requirement of allocating some memory to free some memory. I am also Ok with GFP_ATOMIC with the GFP_NOWARN removed, if you are Ok with that. thanks, - Joel