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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 8DB81C2D0F0 for ; Wed, 1 Apr 2020 13:15:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 460092073B for ; Wed, 1 Apr 2020 13:15:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 460092073B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EA51D8E0006; Wed, 1 Apr 2020 09:15:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7D328E0001; Wed, 1 Apr 2020 09:15:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D93498E0006; Wed, 1 Apr 2020 09:15:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id C1A6B8E0001 for ; Wed, 1 Apr 2020 09:15:32 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 88769248E for ; Wed, 1 Apr 2020 13:15:32 +0000 (UTC) X-FDA: 76659332904.18.slope02_87a889577965d X-HE-Tag: slope02_87a889577965d X-Filterd-Recvd-Size: 5564 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Apr 2020 13:15:32 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id m11so24653268wrx.10 for ; Wed, 01 Apr 2020 06:15:31 -0700 (PDT) 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; bh=4nqvkqNGMuXID7lI1fswCDVvlcVmjjuU+dPdiaYDon8=; b=Fdq0m021r/Mb5CLLoMgU5wMyoaXPPKRd4FR7HreJfMd54tJPZxQYDpLAXoDYf8RJV0 9Wrmsx37i/3O63UO3YO/v9o3TwLdzt2JP+DWv3unGj59yuCQ1HUzOyHJNEDjZ8SyXBxT xjjwGvzI1DEILf7jfqGBtTW/uBc/AslltuCSvcFc2C59bp3m9tpfZ4/rR7GDMxXN3p6d v5lZ+7uC5npN2iWqdsjoaroVMOowOpfmIuBAPIOh/VnZ2QePz+bSs9sNRbNge/dYxiyY cryzkLUli6kqVpulsT5QemrB/ldcQXV5f6llrvDiyZDeodTqs/fiVCzV9P3hUaXnoKsm Uf7w== X-Gm-Message-State: ANhLgQ2dvI6gnZ0snUtLisSK2V6/VNPWoYzv0F61MKIUq57oNrRJc5e9 bMX6614dECF/KbYDPVkuSMY= X-Google-Smtp-Source: ADFU+vuLQ5n4h2oATutOYE6daFLh+JwtCBKG5iEDDxu7W0Ra0C4tfAkK3wF9YRRGd1pPcMZnI7nwYA== X-Received: by 2002:a5d:49c8:: with SMTP id t8mr26498357wrs.5.1585746930942; Wed, 01 Apr 2020 06:15:30 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id t10sm2651323wrx.38.2020.04.01.06.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 06:15:30 -0700 (PDT) Date: Wed, 1 Apr 2020 15:15:28 +0200 From: Michal Hocko To: Uladzislau Rezki Cc: Joel Fernandes , 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: <20200401131528.GK22681@dhcp22.suse.cz> References: <20200331131628.153118-1-joel@joelfernandes.org> <20200331145806.GB236678@google.com> <20200331153450.GM30449@dhcp22.suse.cz> <20200331161215.GA27676@pc636> <20200401070958.GB22681@dhcp22.suse.cz> <20200401123230.GB32593@pc636> <20200401125503.GJ22681@dhcp22.suse.cz> <20200401130816.GA1320@pc636> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200401130816.GA1320@pc636> 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 Wed 01-04-20 15:08:16, Uladzislau Rezki wrote: > On Wed, Apr 01, 2020 at 02:55:03PM +0200, Michal Hocko wrote: > > On Wed 01-04-20 14:32:30, Uladzislau Rezki wrote: > > > On Wed, Apr 01, 2020 at 09:09:58AM +0200, Michal Hocko wrote: > > > > On Tue 31-03-20 18:12:15, Uladzislau Rezki wrote: > > > > > > > > > > > > __GFP_ATOMIC | __GFP_HIGH is the way to get an additional access to > > > > > > memory reserves regarless of the sleeping status. > > > > > > > > > > > Michal, just one question here regarding proposed flags. Can we also > > > > > tight it with __GFP_RETRY_MAYFAIL flag? Means it also can repeat a few > > > > > times in order to increase the chance of being success. > > > > > > > > yes, __GFP_RETRY_MAYFAIL is perfectly valid with __GFP_ATOMIC. Please > > > > note that __GFP_ATOMIC, despite its name, doesn't imply an atomic > > > > allocation which cannot sleep. Quite confusing, I know. A much better > > > > name would be __GFP_RESERVES or something like that. > > > > > > > OK. Then we can use GFP_ATOMIC | __GFP_RETRY_MAYFAIL to try in more harder > > > way. > > > > Please note the difference between __GFP_ATOMIC and GFP_ATOMIC. The > > later is a highlevel flag to use for atomic contexts. The former is an > > explicit way to give an access to memory reserves. I am not familiar > > with your code but if you have an existing gfp context coming from the > > caller then just do (gfp | __GFP_ATOMIC | __GFP_HIGH | __GFP_RETRY_MAYFAIL). > > If you do not have any gfp then decide based on whether the current > > context is allowed to sleep > > gfp = GFP_KERNEL | __GFP_ATOMIC | __GFP_HIGH | __GFP_RETRY_MAYFAIL; > > if (!sleepable) > > gfp &= ~__GFP_DIRECT_RECLAIM; > > We call it from atomic context, so we can not sleep, also we do not have > any existing context coming from the caller. I see that GFP_ATOMIC is high-level > flag and is differ from __GFP_ATOMIC. It is defined as: > > #define GFP_ATOMIC (__GFP_HIGH|__GFP_ATOMIC|__GFP_KSWAPD_RECLAIM) > > so basically we would like to have __GFP_KSWAPD_RECLAIM that is included in it, > because it will also help in case of high memory pressure and wake-up kswapd to > reclaim memory. > > We also can extract: > > __GFP_ATOMIC | __GFP_HIGH | __GFP_RETRY_MAYFAIL | __GFP_KSWAPD_RECLAIM > > but that is longer then > > GFP_ATMOC | __GFP_RETRY_MAYFAIL OK, if you are always in the atomic context then GFP_ATOMIC is sufficient. __GFP_RETRY_MAYFAIL will make no difference for allocations which do not reclaim (and thus not retry). Sorry this was not clear to me from the previous description. -- Michal Hocko SUSE Labs