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 7CDEBC4345F for ; Fri, 26 Apr 2024 15:18:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 171A46B00A2; Fri, 26 Apr 2024 11:18:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 129E06B00A3; Fri, 26 Apr 2024 11:18:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F28C26B00A4; Fri, 26 Apr 2024 11:18:50 -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 D44B76B00A2 for ; Fri, 26 Apr 2024 11:18:50 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 87A53A22CC for ; Fri, 26 Apr 2024 15:18:50 +0000 (UTC) X-FDA: 82052040420.03.D7F6B89 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf25.hostedemail.com (Postfix) with ESMTP id 4A690A0017 for ; Fri, 26 Apr 2024 15:18:47 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=c4y7MUDF; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714144729; 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=hAlfIXDOxQlmd9QKb4RO75kaAW8nVyDZWahBKipi7a4=; b=xs4mFPTZnV9v2kWyh93uzwmzduZ9l0bEx01zfs6ifKxtmukQ7Cax04dv5Wvq/LA3FiNjrI 69lOcAyYoOsha5qC4yKh9tTXoO0GIUTeE7QMdzX8CZ1MGG9yf0f5M0vi0H7Ri9HJEhqrFH 6y9HFPAlVLxx5qcV7y9pWNX+qj22ODo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=c4y7MUDF; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714144729; a=rsa-sha256; cv=none; b=Z97pTFZ8khf3cVEsrA2jhuDc028p7G8+/i2GgUWyQg/7/wOiHUc1TVl7Afb6XCPWab9REN PsmPHIevIb0nUa+Oz88pmdoBT+ODDyf4lNdhSiL6bEeSPs6g9lJ0CrOTQZKMiumzyl6Wby swWxBUNMI31h07kLRvqRb8k37ATtXuA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5D6E9CE1C8D; Fri, 26 Apr 2024 15:18:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77878C113CD; Fri, 26 Apr 2024 15:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714144724; bh=iMSfAGShKd7YbJ5VcD2YOia5ZlLkkptKg528JtHK0kI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c4y7MUDFUSoWtSFhptFDidEtAkjexq+z9Djlt/GbttVvkxEnjl3ydqNclRY1n/TtZ 92PRSZsFmO1P58TrQWvFhbJY7Dxu1ChOiSgA6jmeTzuqC5y53cd/q+/wQDztfTk4CP LAFFhr0oNYqq+tyuKN3mEtXliPa5g5099kskUNDPiIwa00jDaNcQfTxEJ8Y1aAipMe iKMGWT9ekThd9mhtyvihorTIQLZvC+z/DPbp+TG48LJ2hEM41WzGfEjUcvGgFm7Flf 8kfKIt5AoYHbfTakwI+QQUPRC4O8lHA2dkb65+mlGxtf9kh7mmQ68Qe08nTs4mz+oN 8sjT+izzxOCRw== Date: Fri, 26 Apr 2024 08:18:44 -0700 From: "Darrick J. Wong" To: "Pankaj Raghav (Samsung)" Cc: willy@infradead.org, brauner@kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, hare@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, Dave Chinner Subject: Re: [PATCH v4 08/11] xfs: use kvmalloc for xattr buffers Message-ID: <20240426151844.GH360919@frogsfrogsfrogs> References: <20240425113746.335530-1-kernel@pankajraghav.com> <20240425113746.335530-9-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240425113746.335530-9-kernel@pankajraghav.com> X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4A690A0017 X-Stat-Signature: 4bsjn6oxpxzeuxk8ui9mqboderfwwze4 X-HE-Tag: 1714144727-870095 X-HE-Meta: U2FsdGVkX19EDUeqjLQr1/4gCqMAWUGlRNU3n3ce5PJNXYtYA5q+Tt1s8UbG8Hw1DeBLDlvMHsBI6i1EjxiQkw2NEi37eU7UNuBjU7T3nAAuCzxH+Gmx/xzM7PtyVI4ZM5Wy0S3xRAhQEz2F1mQzUijHWBO24LW8XVzomjb+NxqDeOPeVzyi+RJWOmFFlitLdF1wfqNkYs323ZAc9/n/6siCLC90Eq48sA5SVv4Bdu25d+9pBf/PFI007OCRCP6SlBf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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, Apr 25, 2024 at 01:37:43PM +0200, 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 Didn't this already go in for-next? If not, Reviewed-by: Darrick J. Wong --D > --- > 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 ac904cc1a97b..969abc6efd70 100644 > --- a/fs/xfs/libxfs/xfs_attr_leaf.c > +++ b/fs/xfs/libxfs/xfs_attr_leaf.c > @@ -1059,10 +1059,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; > @@ -1125,7 +1122,7 @@ xfs_attr3_leaf_to_shortform( > error = 0; > > out: > - kfree(tmpbuffer); > + kvfree(tmpbuffer); > return error; > } > > @@ -1533,7 +1530,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; > @@ -1571,7 +1568,7 @@ xfs_attr3_leaf_compact( > */ > xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1); > > - kfree(tmpbuffer); > + kvfree(tmpbuffer); > } > > /* > @@ -2250,7 +2247,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); > > /* > @@ -2291,7 +2288,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.34.1 > >