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 5F9A6C71159 for ; Thu, 19 Jun 2025 04:16:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD8B46B00A2; Thu, 19 Jun 2025 00:16:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB0106B00A3; Thu, 19 Jun 2025 00:16:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC5F56B00A4; Thu, 19 Jun 2025 00:16:53 -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 B9BCA6B00A2 for ; Thu, 19 Jun 2025 00:16:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 20624BF7F4 for ; Thu, 19 Jun 2025 04:16:53 +0000 (UTC) X-FDA: 83570839506.07.74DC217 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) by imf26.hostedemail.com (Postfix) with ESMTP id 1A8B5140008 for ; Thu, 19 Jun 2025 04:16:50 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="XWBhB/oC"; spf=pass (imf26.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.177 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750306611; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jLkDzHDT1DpdO9SvwjUVcY89+HsbQoXPc++y60o2jdw=; b=X837KY3+Y1z90cDCpHhCLY9kTIPd1qtVjfLvu7+S7zkHMMp/SJzwSgLx7FJTTVOc77AX0k xtMioEa53HdHgXRFOi1zE8u6g8X9mNiHzvucoRWIeofoZuhDPNd3/0gBTwapNW0WL+0hTp 0Itf6AZYNQgCDQDhn44omIDOap8x+jo= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="XWBhB/oC"; spf=pass (imf26.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.177 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750306611; a=rsa-sha256; cv=none; b=47wm8AEfRkCZW6FKYPdNs+roivFCl5DW8XvOtxcvSXq0MDzQIyIvRefX9D8sW6VFHxFIND 8dcTI4g92nnK+j+GpEdr2FfH2dxduFShig7eEp5wmLhDlmhnFd13dG0WJKoElD2e68dUJx YRvJU/QErjQc53mJ1ib93Id3tflx8HE= Date: Thu, 19 Jun 2025 00:16:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1750306608; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jLkDzHDT1DpdO9SvwjUVcY89+HsbQoXPc++y60o2jdw=; b=XWBhB/oCx8Xq0M2997Dmmqy/lPiH9P1wDkClwlGxOwFsMgqwkQLi99Thsv4IpmyKlYbrTQ fZJBNz2w17VkoUi1rJYs6jaX65Paze7olS8Q8U84di4faPvxawpvP5lPBkWToxVRnkR5rB JSmOkjEMkzRGmpU9yMVWqHhGdxt5rlY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Zhongkun He Cc: Andrew Morton , mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [External] Re: [PATCH] mm: rename the oldflags and parameter in memalloc_flags_*() Message-ID: References: <20250618070328.2192849-1-hezhongkun.hzk@bytedance.com> <20250618164334.54616cb2d70a1ee3c1f28a81@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1A8B5140008 X-Stat-Signature: kjeohfw5tjnou57fwmg1c1shdiztb44e X-HE-Tag: 1750306610-497915 X-HE-Meta: U2FsdGVkX19/acJ0U9hF9j+2/rKHI0qIb1EP4BRw7DSmZ6BRoDmKQXzQCr4yg3V11z4RXe8dci2m7twkEF+F2+3Ofq84XZWFXy1VZ/d9+9KIPK83T5WpRPhb8uPBjyb3Hs8BHF0BSf24Y7BVIb3qWRcR+5Ev+hcQIOaSaaMpErgEgloXGGbxg4yu4p7nI9+91x9BPad44DDq+e5STQcy9eOYqEXIuoBO0DAB56r3GRbSwyk9lqty7BKQF/RkMt6GkfwLIEIBylYxRrj1s9jk6W35KamLetXGCW9JrWFfn/YyPm9s5OX4j2rEkBdCoMkbqcfR2dK/Sa5ANssVMaxQlPQer/+pXevw53V4zRKu6wAnQVUCPOfysmOW/H33BQ/WpwExBzrAstItteNr0rky3pRB0NQPbKTvq8QHZtIINBDsxFuAjNiixR5RAzyWvrSwkp2ROqExI7mqSolStbRAadQRLG9W6X9DNJA9K2UU1NQvcmBRSz4YwnrW9LOeI3Q4cc2+3+KEWVL9UUR2sJZeQxvmlJAI85srtvRK4HYYBH/KUAXonBE2M/o3XXzLpa3j0f5/O9EpHo8BdNDb3SXgG09wQzl2jfy4Ezv6P9fLGiW2gBigmKpJlr83yy8YCD6jHx9r4Yk9kpl6UWkTIkT9JfPP7b1iILZzT+ZkImmqppusvWuJfkP0/OzNEOZ2NJQT3GyANsam42EzeCMqhci0kmXfSOEJhmqCCMF1FX8c47SJMVXpKO702E3PImo3DNJcOh6DW0Un+A8MWEdmL3LuFqXqFOANMOQaSamJW49X0GeJrzpAG5fMnyxBz3aKZ7gXlnOBj29joPv3nVkYFLVphGxR6IKVGgotcuqNBZmZgoFfyR/yisA2My7AV24ebrGprg9K4iWNaOmG8sK83cPfXDJvfZhwDyjEieR+F6TnBtt/h4AnSQWwpHdOyDqzkJCMMCsfmpTWGaN3TxAMVuj UCO5HIn8 Mka04PEuopiVLibA2Fi4jWS/qY2ZZ7kuufKkNYskiyrJCnoctKa7iNTmbSZlI0k8EHJ0/taeQ74Sy+M3CirJodicPBGcgBPPyTdAtIOi2QrmwEwFgKht7WOiaOEMZnpd3iHQveTZETYJ/8oM/fyqt5KEQEJFfas/N4jOYc0WbElL+YmDdSH+5Vjziah3Zroj+tyGH56MtARmOAIdeCMv3aChGy+NKSFeiHWc4aYkFL7opq5zurQJfmpa7FcjgRViFdBJVQwEoz2CYlu2MHQ3PSDuXMNcuWeWBta8N2di1UPC4CVpfoULWsJSMufiXmTEDY6XCE7iPwO+IvF5Yg/CoPpFdXg== 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: List-Subscribe: List-Unsubscribe: On Thu, Jun 19, 2025 at 11:17:58AM +0800, Zhongkun He wrote: > On Thu, Jun 19, 2025 at 8:07 AM Kent Overstreet > wrote: > > > > On Wed, Jun 18, 2025 at 04:43:34PM -0700, Andrew Morton wrote: > > > On Wed, 18 Jun 2025 15:03:28 +0800 Zhongkun He wrote: > > > > > > > The variable name oldflags can indeed be misleading, because > > > > it does not store the complete original value of flags. > > > > Instead, it records which flags from the given set are not > > > > currently set. So rename it. > > > > > > > > > > Your email client is mangling the patches in strange ways. Please send > > > yourself a patch, figure out why it didn't apply? > > > > > > > --- a/include/linux/sched/mm.h > > > > +++ b/include/linux/sched/mm.h > > > > @@ -322,21 +322,21 @@ static inline void might_alloc(gfp_t gfp_mask) > > > > } > > > > > > > > /** > > > > - * memalloc_flags_save - Add a PF_* flag to current->flags, save old value > > > > + * memalloc_flags_save - Add a PF_* flag to current->flags, return saved flags mask > > > > * > > > > * This allows PF_* flags to be conveniently added, irrespective of current > > > > * value, and then the old version restored with memalloc_flags_restore(). > > > > */ > > > > -static inline unsigned memalloc_flags_save(unsigned flags) > > > > +static inline unsigned int memalloc_flags_save(unsigned int flags_mask) > > > > { > > > > - unsigned oldflags = ~current->flags & flags; > > > > - current->flags |= flags; > > > > - return oldflags; > > > > + unsigned int saved_flags_mask = ~current->flags & flags_mask; > > > > + > > > > + current->flags |= flags_mask; > > > > + return saved_flags_mask; > > > > } > > > > > > > > -static inline void memalloc_flags_restore(unsigned flags) > > > > +static inline void memalloc_flags_restore(unsigned int flags_mask) > > > > { > > > > - current->flags &= ~flags; > > > > + current->flags &= ~flags_mask; > > > > } > > > > > > I guess so. Maybe. A bit. Kent, what do you think? > > > > Eesh, seems like pointless verbosity to me. Maybe don't change it if it > > doesn't need to be changed? > > Hi Kent, thanks for your feedback. > How about this version, only change the 'old' to 'saved'. > The function does not return the old current->flags value. Instead, > it returns the subset of flags that were not previously set in current->flags, > so they can later be cleared by memalloc_flags_restore(). The name savedflags > makes this behavior clearer and avoids confusion. Why change it at all? The returned flags parameter is opaque state that should only be used by memalloc_flags_restore(), it's not something the caller should be looking at. > > /** > - * memalloc_flags_save - Add a PF_* flag to current->flags, save old value > + * memalloc_flags_save - Add a PF_* flag to current->flags, return saved flags > * > * This allows PF_* flags to be conveniently added, irrespective of current > * value, and then the old version restored with memalloc_flags_restore(). > */ > static inline unsigned memalloc_flags_save(unsigned flags) > { > - unsigned oldflags = ~current->flags & flags; > + unsigned savedflags = ~current->flags & flags; > current->flags |= flags; > - return oldflags; > + return savedflags; > } > > Thanks, > Zhongkun