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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50036C433EF for ; Wed, 25 May 2022 13:12:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3D178D0005; Wed, 25 May 2022 09:12:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE9A78D0001; Wed, 25 May 2022 09:12:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B0658D0005; Wed, 25 May 2022 09:12:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8B5658D0001 for ; Wed, 25 May 2022 09:12:08 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5B0DA21368 for ; Wed, 25 May 2022 13:12:08 +0000 (UTC) X-FDA: 79504303536.07.43839BF Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf10.hostedemail.com (Postfix) with ESMTP id A77F1C001D for ; Wed, 25 May 2022 13:11:30 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id v6so13830009qtx.12 for ; Wed, 25 May 2022 06:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DRlg5c8ylNh5PSHKrNNBpxR43/W9/VLsRV/iCMocZ0U=; b=Ux3JSCmqOoRojgkP0EYey8DO/n8s1DJL5kHW/U7IfULdVVqH2vJJ0mIqHlNtL3mBs/ tkIdUp7KLMi8YuXqNZ+h/sL/ESRmtB668iX86lI9dKtr9hydQ4ovURIpNcAJw13pjMrD 7iua/1Xlnr53dQwAHKj7yjC9SRe5AeHWJ5VS9/lAI5tNALHL5hloyJ68HC+ulVjvj5xz ra1bXZaxJzmGrxT+M9zmNS7YuGqo+6IV0JcuuirEulHL6Wm3gJpblkVucPbJ+r3opOjK e63qd2PK0MRfDoCruUgqDb8+b8SIPr70j1gGo/LzjYC9HeQouVaR0FpmqNGXE9x6Dgr6 vEXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DRlg5c8ylNh5PSHKrNNBpxR43/W9/VLsRV/iCMocZ0U=; b=fk3l9Z++eNMZyt+7R2iDQhhXrnO104WLgxYFCYi0X0dOul02O9Ml+cVjlkmvulzB6t tJyk9Uo7b5stRs4GOB1qA5y9JPrDxCKSNB3bGlAhyoidw/AQAG4V87Y2eK5Zl4OPb5EE V2QGa4tmyVGvzv7b/2FR/i7rbb+ug6BT/uFbYJhN26eZDU0pthWcJyatzVpsYsGAtAK8 03aeDNiM/k2cqwho9md9oUujesUXNCFzgrQwX7wJ58XUFIftymvigUKC7F7cUX63jHFo 6oG0f32AgaOwZDB+HkLAhdb2ndTo7ROYrfisDk+g4kjFezoMwuQmHJLAS9sV4luvZQy1 3o9A== X-Gm-Message-State: AOAM530uVKAS2F5TzJwJljcSrAkKdwsXKc4UWAZDbM7fcegvooSDGtTS u76+2WzvCghxi3+96pmI2/NhjQ== X-Google-Smtp-Source: ABdhPJwHuJEO5WEgjEkEkOz/ET7ou1QmBPjdjVacMERfxgWwoIwkd2WANDeV4Hn3VSfBPl+0e+VfRQ== X-Received: by 2002:a05:622a:1484:b0:2f3:c837:57a6 with SMTP id t4-20020a05622a148400b002f3c83757a6mr24561524qtx.460.1653484326780; Wed, 25 May 2022 06:12:06 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:741f]) by smtp.gmail.com with ESMTPSA id s12-20020a05620a030c00b006a36dedb53bsm1197381qkm.45.2022.05.25.06.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 06:12:06 -0700 (PDT) Date: Wed, 25 May 2022 09:12:05 -0400 From: Johannes Weiner To: Vlastimil Babka Cc: Suren Baghdasaryan , Matthew Wilcox , "Paul E. McKenney" , Michal Hocko , "Liam R. Howlett" , Michel Lespinasse , linux-mm , LKML , David Hildenbrand , Davidlohr Bueso Subject: Re: Memory allocation on speculative fastpaths Message-ID: References: <20220503155913.GA1187610@paulmck-ThinkPad-P17-Gen-1> <20220503163905.GM1790663@paulmck-ThinkPad-P17-Gen-1> <1a0a859b-1f25-5136-bb86-9efe68aabbb8@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1a0a859b-1f25-5136-bb86-9efe68aabbb8@suse.cz> X-Rspam-User: X-Rspamd-Queue-Id: A77F1C001D X-Stat-Signature: rsippsk83eatm66e9teyc8uwc54rni1d Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=Ux3JSCmq; spf=pass (imf10.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspamd-Server: rspam03 X-HE-Tag: 1653484290-262067 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, May 24, 2022 at 10:37:15PM +0200, Vlastimil Babka wrote: > On 5/4/22 18:23, Johannes Weiner wrote: > > On Tue, May 03, 2022 at 04:15:46PM -0700, Suren Baghdasaryan wrote: > >> On Tue, May 3, 2022 at 11:28 AM Matthew Wilcox wrote: > >>> > >>> On Tue, May 03, 2022 at 09:39:05AM -0700, Paul E. McKenney wrote: > >>>> On Tue, May 03, 2022 at 06:04:13PM +0200, Michal Hocko wrote: > >>>>> On Tue 03-05-22 08:59:13, Paul E. McKenney wrote: > >>>>>> Hello! > >>>>>> > >>>>>> Just following up from off-list discussions yesterday. > >>>>>> > >>>>>> The requirements to allocate on an RCU-protected speculative fastpath > >>>>>> seem to be as follows: > >>>>>> > >>>>>> 1. Never sleep. > >>>>>> 2. Never reclaim. > >>>>>> 3. Leave emergency pools alone. > >>>>>> > >>>>>> Any others? > >>>>>> > >>>>>> If those rules suffice, and if my understanding of the GFP flags is > >>>>>> correct (ha!!!), then the following GFP flags should cover this: > >>>>>> > >>>>>> __GFP_NOMEMALLOC | __GFP_NOWARN > >>>>> > >>>>> GFP_NOWAIT | __GFP_NOMEMALLOC | __GFP_NOWARN > >>>> > >>>> Ah, good point on GFP_NOWAIT, thank you! > >>> > >>> Johannes (I think it was?) made the point to me that if we have another > >>> task very slowly freeing memory, a task in this path can take advantage > >>> of that other task's hard work and never go into reclaim. So the > >>> approach we should take is: > > > > Right, GFP_NOWAIT can starve out other allocations. It can clear out > > the freelists without the burden of having to do reclaim like > > everybody else wanting memory during a shortage. Including GFP_KERNEL. > > FTR, I wonder if this is really true, given the suggested fallback. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ IIRC adding this fallback was the conclusion of the in-person discussion. Above I just tried to summarize for the record the original concern that led to it. I could have been more clear. Your analysis is dead on, of course.