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=-5.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 C1CB1C2D0F1 for ; Tue, 31 Mar 2020 16:01:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7DD6320784 for ; Tue, 31 Mar 2020 16:01:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="iTuWUT6v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DD6320784 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A8236B0032; Tue, 31 Mar 2020 12:01:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 258726B0037; Tue, 31 Mar 2020 12:01:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1950E6B006C; Tue, 31 Mar 2020 12:01:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 0296F6B0032 for ; Tue, 31 Mar 2020 12:01:19 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C1BAB82499B9 for ; Tue, 31 Mar 2020 16:01:19 +0000 (UTC) X-FDA: 76656121878.22.drum48_45bc4ae1b4c60 X-HE-Tag: drum48_45bc4ae1b4c60 X-Filterd-Recvd-Size: 5615 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 31 Mar 2020 16:01:19 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id d11so23554897qko.3 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=sXT4snxVtfD7sh3lz8VhcC6yw43JR3ejtTFtaXLX3O14BOX8GGdbPE+jBqU2FXw7LX TrP3BHbknPePjmYp1IFqsSiAQE1auPhX+668XO2pjEVQSEGpj4M965kOpBBIVhXefKCg pl1nR9Z3FpvDCeBkTU9IcOCkFUeZzzw158I59iKR3qKv0PRyDn5EP+76s7AUC9yMijSn LCW0u9V9LnsS91gV8zGRVawb+z1mZDIx58LTxaTZ1UvpzovZgNwBYxIiD8wvAz+joQut m7gQl3Lm/LwK4/lnuT6F8v3ryIKflFWVRzJ47S3S1Ue3OxURwGiin1qOTRA6zossT7hH lCpA== X-Gm-Message-State: AGi0PuZJHZm+VtPqs+qR6bQWtdGrsruolrclqVX7dSVQR1lHczXmLL4F xA/wrRP+RbARzDj6cGMKjeLF8Q== X-Google-Smtp-Source: APiQypJlQCeOHLVheNSd8NA+Re55P3E8j2hVLv1JFketxo3lxvPNs0ci4X6V6rEh2Rw+3VC64pNnJQ== 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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