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 9DB32C2BBCA for ; Tue, 25 Jun 2024 18:07:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DCBE6B00AD; Tue, 25 Jun 2024 14:07:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28D636B00AE; Tue, 25 Jun 2024 14:07:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 154456B00AF; Tue, 25 Jun 2024 14:07:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EDE156B00AD for ; Tue, 25 Jun 2024 14:07:30 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6F182A031D for ; Tue, 25 Jun 2024 18:07:30 +0000 (UTC) X-FDA: 82270193460.08.FF6346E Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf25.hostedemail.com (Postfix) with ESMTP id 72ED4A0003 for ; Tue, 25 Jun 2024 18:07:28 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=vSe2sDHF; spf=pass (imf25.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719338834; 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=LzWBYB2Gv7p9oshvlsKyQsodiqzS1M8ZSWboiFntUYM=; b=SSb/MoeD+DY7tpPXwf5stangX4DJAK8nJKLdM/hemzfTfDavhog8tx6SjwpzioEmZCBXUk zgRaO1LRqhnp9BGGl8CaDZiakeilB2JqROwfxDtYSx89hEEKR4TD4tkefDDCJQSyRz8Szq ZtvmEGbKsFMp1UmpkPIaba1EWCNg1Po= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719338834; a=rsa-sha256; cv=none; b=tj565gCTxsHry04C1Jg9jGwBFc8q+OpO7MooLnmoyPbhyrxcA6Etqf/u3AaUQF+70PGg/E mvf061uggBlpFTBiSiei2NA8IhEDbW38VCqdZ90LWD26DaSdQNJK58wZf5O0GXXADUKkoj PYKM6L6J7H4DCFGt6a5Jlp6XvHJdQW8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=vSe2sDHF; spf=pass (imf25.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4W7t8X471xz9spX; Tue, 25 Jun 2024 20:07:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1719338844; 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: in-reply-to:in-reply-to:references:references; bh=LzWBYB2Gv7p9oshvlsKyQsodiqzS1M8ZSWboiFntUYM=; b=vSe2sDHFQLJAI2F32jwY/9aqW9fO4IhYAUQw8hSEDq5R4aIt2It3K61jhJC1EglU9M0AY7 JkUsyCIpukvFE6g2oRaAh7ds1J6Smwu7sqcsWIEFUCSlB/aGvUVYQb5usf6/K3mS+FJbr5 AibDi6KTwCI91f40QVKQOK0EmVAQVHFllW3mu1F3drbhzmOnGRSrqLxqJFQKMhngLinij4 32n1Ui7nKfS64z7gewXlECNAqCkcWnEpvkK25pf2RfaPwCqacsv2eNd36TSq2m6eY//NTG XUQuuNd7VPpcGss4hSidOh5HOagE5Dl5P8cvLm+V/PRuIpquJDdTD8Xvpvo+6Q== Date: Tue, 25 Jun 2024 18:07:20 +0000 From: "Pankaj Raghav (Samsung)" To: david@fromorbit.com, willy@infradead.org, chandan.babu@oracle.com, djwong@kernel.org, brauner@kernel.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, yang@os.amperecomputing.com, linux-mm@kvack.org, john.g.garry@oracle.com, linux-fsdevel@vger.kernel.org, hare@suse.de, p.raghav@samsung.com, mcgrof@kernel.org, gost.dev@samsung.com, cl@os.amperecomputing.com, linux-xfs@vger.kernel.org, hch@lst.de, Zi Yan , Dave Chinner Subject: Re: [PATCH v8 07/10] xfs: use kvmalloc for xattr buffers Message-ID: <20240625180720.ali2zno6f62u3pi7@quentin> References: <20240625114420.719014-1-kernel@pankajraghav.com> <20240625114420.719014-8-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240625114420.719014-8-kernel@pankajraghav.com> X-Rspamd-Queue-Id: 72ED4A0003 X-Stat-Signature: q1pws1uu4a9sr9p11pohfnduim1da39k X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719338848-886400 X-HE-Meta: U2FsdGVkX1/UZi3tg1QC+RAY3c5+mUDFPKYLkf6tUNDmu7s5duISFE9SnWkphxKTKJS5R3OxpJ5nUSL/kSGsDAaifi1k7hPh9Xn9SUq2tB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QPQZQoIIIXX4BuPO9i6qfmOWIvEDbumgJdtJ/MH5l8FVNZuQnJ+QCGRd5cR08pwkuy2hWSwZVo8g3GwDJ3+vwsNd43MtFzwNFvfa1DZAD/LFYDFZWLenBw77f68do/uqaZAVeXpdnhBoGU68TzerK+GQwvA/sUm/yg7adukRgWgwPvpehkaVGImi/foOlemY= 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 Tue, Jun 25, 2024 at 11:44:17AM +0000, Pankaj Raghav (Samsung) wrote: > From: Dave Chinner > > Pankaj Raghav reported that when filesystem block size is larger > than page size, the xattr code can use kmalloc() for high order > allocations. This triggers a useless warning in the allocator as it > is a __GFP_NOFAIL allocation here: > > static inline > struct page *rmqueue(struct zone *preferred_zone, > struct zone *zone, unsigned int order, > gfp_t gfp_flags, unsigned int alloc_flags, > int migratetype) > { > struct page *page; > > /* > * We most definitely don't want callers attempting to > * allocate greater than order-1 page units with __GFP_NOFAIL. > */ > >>>> WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1)); > ... > > Fix this by changing all these call sites to use kvmalloc(), which > will strip the NOFAIL from the kmalloc attempt and if that fails > will do a __GFP_NOFAIL vmalloc(). > > This is not an issue that productions systems will see as > filesystems with block size > page size cannot be mounted by the > kernel; Pankaj is developing this functionality right now. > > Reported-by: Pankaj Raghav > Fixes: f078d4ea8276 ("xfs: convert kmem_alloc() to kmalloc()") > Signed-off-by: Dave Chinner > Reviewed-by: Darrick J. Wong > Reviewed-by: Pankaj Raghav @Chandan: As we discussed today, do you want to pick this up for 6.11? Then I can drop it from my patch series. > --- > fs/xfs/libxfs/xfs_attr_leaf.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c > index b9e98950eb3d..09f4cb061a6e 100644 > --- a/fs/xfs/libxfs/xfs_attr_leaf.c > +++ b/fs/xfs/libxfs/xfs_attr_leaf.c > @@ -1138,10 +1138,7 @@ xfs_attr3_leaf_to_shortform( > > trace_xfs_attr_leaf_to_sf(args); > > - tmpbuffer = kmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); > - if (!tmpbuffer) > - return -ENOMEM; > - > + tmpbuffer = kvmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); > memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); > > leaf = (xfs_attr_leafblock_t *)tmpbuffer; > @@ -1205,7 +1202,7 @@ xfs_attr3_leaf_to_shortform( > error = 0; > > out: > - kfree(tmpbuffer); > + kvfree(tmpbuffer); > return error; > } > > @@ -1613,7 +1610,7 @@ xfs_attr3_leaf_compact( > > trace_xfs_attr_leaf_compact(args); > > - tmpbuffer = kmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); > + tmpbuffer = kvmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL); > memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); > memset(bp->b_addr, 0, args->geo->blksize); > leaf_src = (xfs_attr_leafblock_t *)tmpbuffer; > @@ -1651,7 +1648,7 @@ xfs_attr3_leaf_compact( > */ > xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1); > > - kfree(tmpbuffer); > + kvfree(tmpbuffer); > } > > /* > @@ -2330,7 +2327,7 @@ xfs_attr3_leaf_unbalance( > struct xfs_attr_leafblock *tmp_leaf; > struct xfs_attr3_icleaf_hdr tmphdr; > > - tmp_leaf = kzalloc(state->args->geo->blksize, > + tmp_leaf = kvzalloc(state->args->geo->blksize, > GFP_KERNEL | __GFP_NOFAIL); > > /* > @@ -2371,7 +2368,7 @@ xfs_attr3_leaf_unbalance( > } > memcpy(save_leaf, tmp_leaf, state->args->geo->blksize); > savehdr = tmphdr; /* struct copy */ > - kfree(tmp_leaf); > + kvfree(tmp_leaf); > } > > xfs_attr3_leaf_hdr_to_disk(state->args->geo, save_leaf, &savehdr); > -- > 2.44.1 >