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 D1765C83F12 for ; Thu, 29 Aug 2024 12:34:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18F236B007B; Thu, 29 Aug 2024 08:34:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 140C86B0083; Thu, 29 Aug 2024 08:34:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F21446B0085; Thu, 29 Aug 2024 08:34:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D30F86B007B for ; Thu, 29 Aug 2024 08:34:13 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 665A31204FB for ; Thu, 29 Aug 2024 12:34:13 +0000 (UTC) X-FDA: 82505225586.30.93CB3A8 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by imf25.hostedemail.com (Postfix) with ESMTP id 47097A0016 for ; Thu, 29 Aug 2024 12:34:11 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=I6iyV6or; spf=pass (imf25.hostedemail.com: domain of mhocko@suse.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724934733; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0omIxXdZ2Z1z0cHN/bNiykvs++kigV/Ublbt82Yn504=; b=NISt22bwR6CRoYCOiZSim6TQhfzRHGzAIScSoeZ0SnrYN+kWOTQmGn31XKBocCu/0n+VmK FmP2NXmQqQLzGolvAkmkLYU7mMccDBupNSp1ulUHnNm9YA9umMjCNOJoxXse0p95AVhiYo X4O/P3DA33WZr1fzQiSAHfOCWqz83dM= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=I6iyV6or; spf=pass (imf25.hostedemail.com: domain of mhocko@suse.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724934733; a=rsa-sha256; cv=none; b=BgEy3MVsHv0Z2Lb1jcYJInLdbOitzqQ5t2v6guOB5k6nR8rdMQdB7R4h5gzOK2D8k8lptA h8Gw7+sv3CbEC93R4yu/Q332x+/p49J+Rg1snMIc3mARaS44GryuUGcu7oGTZPUk1+DfNx 03v6m1zedXnu2VAqtBx6QHPGeygHV2c= Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-371bb8322b2so346916f8f.0 for ; Thu, 29 Aug 2024 05:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1724934849; x=1725539649; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0omIxXdZ2Z1z0cHN/bNiykvs++kigV/Ublbt82Yn504=; b=I6iyV6ori61Ge2JQH2eVKSzqYVb7aeAFbv5Ph4lnMUv30++AMvH053i58+4XJntYnO nyrHGz8V+PHzNzRyjZmrQvs69C6/af0TC3I0kcZHKpWwrSLkG8THU4ZdC+DQEH7khpIM Uw7CB+puGSZ9rAq/tNbfsM7tkpLC+UX45MILpFK1HzBupBT6b1DWEqJ6qlewvVLxTr6Z EesdnH019yOXEFtNHZZ3+qXd75XrEy6g3V+ROgcqpCbY2+bSYFpDF9ZONNmUiw2XLuEj 2/SNWsViZ9Rwl4V8t/Li4HpTFUCxwsMiC/nC80l3ACfjJtDiKsO612KU6reIoiCRoNTO iX6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724934849; x=1725539649; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0omIxXdZ2Z1z0cHN/bNiykvs++kigV/Ublbt82Yn504=; b=QUUd0JBG3bYQk1g5wQbnL5PzWUQSc7ydynrvvzWjzi3aT260VzJHTR5YFaV1RAnhOM +ZBFyLBZQdzoHTY1Gb95GMNhtZXYWGwTbrrUFPxBX5T+kpzk0NJ1w+zPbV2NTi3hrQBQ OAaSrhOhiSlqOZxs3NOQP3e+LpcKKYQ6Fv4TJ9R8IwOQAzX+p2S+xGk91FxJW6hNuWTL PuO/1Qnl5b7aIJ60rS5VDQ/mAph+W5RW2RWGee911bxx0r2DtnPgrL/R7TUUa6qP4kGN nG+cXvVUkr8mTzwzs2N+LamGyPV/XmX1zxDD1RIIRGQeDweIdQ190htIHznl5/p3ZQeZ IaZA== X-Forwarded-Encrypted: i=1; AJvYcCWt+/kUYZp2WbxocKe85F9NOFFtZ1FGSI2T2ueE5npgpyMDnHNRmrL//TOT1gi4PGnZ2022+HxLaw==@kvack.org X-Gm-Message-State: AOJu0YxK1UMf8j0dp7DTE+d8cifCga2VMRRN+08viQ8Pnw0lwMrmI6hY olS4ppgzPGbn11f3j1//lzUxkyuhD42r1/kE/cVIDagKORfvNhG6sd+QHk093Gs= X-Google-Smtp-Source: AGHT+IHgfsIGgJ6Yfaz6Z5p0OF76oo2Tcpl57sbIiw84kU1rMt9PHEtlVdPlKeTiXsqZV5kEsxLlmw== X-Received: by 2002:adf:fd0a:0:b0:371:6fcf:5256 with SMTP id ffacd0b85a97d-3749c1de10fmr1399945f8f.18.1724934849494; Thu, 29 Aug 2024 05:34:09 -0700 (PDT) Received: from localhost (109-81-82-19.rct.o2.cz. [109.81.82.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6df0a0asm16231425e9.13.2024.08.29.05.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 05:34:09 -0700 (PDT) Date: Thu, 29 Aug 2024 14:34:08 +0200 From: Michal Hocko To: Kent Overstreet Cc: Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Chinner Subject: Re: [PATCH] bcachefs: Switch to memalloc_flags_do() for vmalloc allocations Message-ID: References: <20240828140638.3204253-1-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 47097A0016 X-Stat-Signature: dmt78efkommof9g4ighd88j3czex5k1k X-Rspam-User: X-HE-Tag: 1724934851-624972 X-HE-Meta: U2FsdGVkX1/feyxe4b8lsJPBTWwgFqhAJ0sYABwZBFiCbxLq6vS+2QxWTSPdeeHF9btBYCx0gMHgjDMpQ/M+1OYwr5gAFlNkxJYdEPTsWaWv9JtPq4APmwm29iXSluNVMCgQ1u+zlQVpwXVesmbdw6YsSNzH24eI8Taz5xApeRp1UX59z3Gby4ek4RIi6CsrRWgLPgD+/po+o2tmO6laSeEnP2gsYV08sCk9Y3iBa4yW2gVBrFpS1bb+0B2+QgHB+1d6hkaAWmJsZRKKyoFP6OJSfk19DtO/mQfkba73Aba/A/VUeh5nXN1FwfhMY/zjnrBCREXzoWQr2fxwYJumKbHP8MDSVVwtETQcw3rwdTv8rYy3daZfA/fEL14hIXLiJAQM/FI+SI+f35Ud1xD9ucoJ6of1UM8tlDLUMRfILBveDIhZUVy+CwRkpNOtv/TUwzuf/anFQgLIxVJdavoNtMemV1iDGVhQCuBbCeEXK80vsD8ato0n1QX0i+DoS4/Os+CBPF8zgx2RfjMKAfmtskGfuwDs78n9XyYVQb+j8xswN+OrWPZZjZYby+nLNzKOsu2JDYacVO2jqaGYWV85/JlmrZcVeAgr1cgSoMKERgQq2NjVcRV2pPihlaZ1Yao7hunVaoYXmT7aI5d+XJw4bozEqJaPwh8F68HXMp2zqMOmJxU/vKHVJQWJ5EHouwgWnNk/yBKx88lky8ypi1M00n2gPJbfKDoUyn37GU9bbzdYvCo4G61qBl2D9Xj5Xw4FKsAPaKA6OTocBT3F9gWC0Xi6UxVxCW3S0IElAUVGJkniu0ri43VLhW5HNxmNJ5GRs0HpshtXw0GeUz0IouWu2btZu0fCidM4PZMltthaqzA8OKI/mDGNYeOkr6YfO3OPTmpxtiQNXbeoOyKIyE12WUjxxhdMEBVbO1Q4ZGTOfrOCtuZywF3Tv30Xd8QGhfE78B6PHNMhA/3UxWUnJXb x/yRtPfl /Kp/k0WvbulVUd4aZvMB8m4fyhOPOs6Ggj8hhquHjH0egCw7cNnpNldm9sz47euuPZ0vGYPe2lnIAapxtuh7lPjrWhuZkE4f98NVDWZms++LqJddVNJU3NXAppyTYgDgpHDN8Y4Kd8Y6/cU3Mqt1oKoZbD9RFBq2iIAqf2DAo6BIyaWunoGw1IPs5aOYnSms2MBi4eZnQ1855hJMlSCNVmp1SEqAyaCxiEu8QVcirvyoeJEGT55sXVNaOxXZVDehahRnc7iXvSvZG3tpHj63QYdwPJ50h4sMzLX6Q+jrIXOAleUToFOlSKnMBMT1usuDFyg/QrjyAtMUdVgF+aeuEPN/S0va4utC555Xc X-Bogosity: Ham, tests=bogofilter, spamicity=0.011122, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu 29-08-24 07:55:08, Kent Overstreet wrote: > On Thu, Aug 29, 2024 at 01:08:53PM GMT, Michal Hocko wrote: > > On Wed 28-08-24 18:58:43, Kent Overstreet wrote: > > > On Wed, Aug 28, 2024 at 09:26:44PM GMT, Michal Hocko wrote: > > > > On Wed 28-08-24 15:11:19, Kent Overstreet wrote: > > [...] > > > > > It was decided _years_ ago that PF_MEMALLOC flags were how this was > > > > > going to be addressed. > > > > > > > > Nope! It has been decided that _some_ gfp flags are acceptable to be used > > > > by scoped APIs. Most notably NOFS and NOIO are compatible with reclaim > > > > modifiers and other flags so these are indeed safe to be used that way. > > > > > > Decided by who? > > > > Decides semantic of respective GFP flags and their compatibility with > > others that could be nested in the scope. > > Well, that's a bit of commentary, at least. > > The question is which of those could properly apply to a section, not a > callsite, and a PF_MEMALLOC_NOWAIT (similar to but not exactly the same > as PF_MEMALLOC_NORECLAIM) would be at the top of that list since we > already have a clear concept of sections where we're not allowed to > sleep. Unfortunately a lack of __GFP_DIRECT_RECLAIM means both no reclaim and no sleeping allowed for historical reasons. GFP_NOWAIT is both used from atomic contexts and as an optimistic allocation attempt with a heavier fallback allocation strategy. If you want NORECLAIM semantic then this would need to be represented by different means than __GFP_DIRECT_RECLAIM alone. > And that tells us how to resolve GFP_NOFAIL with other conflicting > PF_MEMALLOC flags: GFP_NOFAIL loses. > > It is a _bug_ if GFP_NOFAIL is accidentally used in a non sleepable > context, and properly labelling those sections to the allocator would > allow us to turn undefined behaviour into an error - _that_ would be > turning kmalloc() into a safe interface. If your definition of safe includes an oops or worse silent failure then yes. Not really safe interface in my book though. E.g. (just randomly looking at GFP_NOFAIL users) btree_paths_realloc doesn't check the return value and if it happened to be called from such a scope it would have blown up. That code is safe without the scope though. There are many other callsites which do not have failure paths. -- Michal Hocko SUSE Labs