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 9BB26C4345F for ; Sun, 28 Apr 2024 21:06:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C77D6B0085; Sun, 28 Apr 2024 17:06:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 178336B0087; Sun, 28 Apr 2024 17:06:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 040266B0088; Sun, 28 Apr 2024 17:06:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D80CB6B0085 for ; Sun, 28 Apr 2024 17:06:49 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1364FA0D7E for ; Sun, 28 Apr 2024 21:06:45 +0000 (UTC) X-FDA: 82060174770.09.6120017 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf05.hostedemail.com (Postfix) with ESMTP id 5C08A100009 for ; Sun, 28 Apr 2024 21:06:43 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hWtochC6; spf=pass (imf05.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 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=1714338403; 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=7yxstpfnkO3d6ouRSTqsWyefS+SUn2WUJo5CNc78Tx4=; b=kfsbyk0Gylh57qo/OG84JzAX6cCwwQLwW4ZxcXl6BV9uLkrREHKklcCYDXgrtzs6JI4uKU ftZlTzqhildLXAU4egloPoLHz2uaK+lvpTc6IRvFRymJ/5keT1wej881ZPA2IQeYBHiup9 3akH2zCnMCUV1M1b+uV788mZAQHAosc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hWtochC6; spf=pass (imf05.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714338403; a=rsa-sha256; cv=none; b=gOSOl19Io9NNFU0QtdfkmWIPhvJvfwRIs1YUwI8QpjkBlOa8Z3bPBE4vsx0NTmF0a7PnWf dB9yCDlHvdjrmkmsBLB7A2YZ20278BBOp3pfdM3hIo2F+5bQmUf0WIpA5ovsolKdauv00W DMnxVRYpL95u+70jhOS6cpXBjHY95Hk= Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-201.mailbox.org (Postfix) with ESMTPS id 4VSJt66fNZz9swb; Sun, 28 Apr 2024 23:06:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1714338398; 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=7yxstpfnkO3d6ouRSTqsWyefS+SUn2WUJo5CNc78Tx4=; b=hWtochC67R8d8LjON5739UYFSl2qdlo+HPeyQ93kCeiu27w1Hc5kL+WNPD3wkURNOl/BFr 0AEX3XZygq/wqsMafbK7aJFuzVrgqcAtYLW4J63F9ClE5twZb3i/+vA6fb8YRMx5eLRFja Sw0QfZAGYZorDd6m5SwYqs2X+FxS6GleGpstNtaA4qOA2re3AplSgIKKvFygBLfccJFc7H O21RkqZHP7OR0vDmRJxJbLfvG7envg7eTtQSZ7EKlfmU8NZn6hVOfrVBAx9bs+J667iWHx DJejx6o/LhM10+X0A5pzYxvafEMWb+1J8U0GN6mQwPV4APY+1E+hVkkbspxBpg== Date: Sun, 28 Apr 2024 21:06:34 +0000 From: "Pankaj Raghav (Samsung)" To: "Darrick J. Wong" 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: <20240428210634.bkarwrwi6rdr6ywx@quentin> References: <20240425113746.335530-1-kernel@pankajraghav.com> <20240425113746.335530-9-kernel@pankajraghav.com> <20240426151844.GH360919@frogsfrogsfrogs> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240426151844.GH360919@frogsfrogsfrogs> X-Stat-Signature: akbehit5to1h9j4sm4hh4n798wyk78na X-Rspamd-Queue-Id: 5C08A100009 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714338403-662982 X-HE-Meta: U2FsdGVkX18e5zTMTPzxSR9KAjKBxKSa2YDO5DS4qTjPy/eZ1lnzmV/SpB/fZm9Vz47A28ercj8jWz2eAJ+d7bN9+6tagZsXaTrhTdd2nt+NohykaJP8lqV6bHO3mDsDC6KttdA2lXh94Ibhmg3D8w1DGdiw18OtVRUbpsA34kLt2g85zzj8P6JP2sB//RCMujfkhu1WOE460/sibmKdXV3vJfXICfktu7mvk1+euYVMT/dpKVdOkB/pDccdzBqQSIh3czRxzycw2KebdG96BZENL22IOd6QSbQfTkFskB+NyzaLc84U/N5GYoT0L0H+skSDJTIJNh1QvgNdy1YcEWsVcf5t5gDhl2u/vItNgSysXHMcSz/lNKG+7+hMzLgK196Cu8Q5uDTckRHOue1qXgLi55sLzodAU+N3iQ2uLWRPcBnsB08K2F/9elJuzez7RU81srG/d8JJgnEA6VOMy872XooUhKWkv3/ZimA6hONTbLb3VaeRT3NIu2QaP1dr9eYuCIgH8Ba3G0Iauvkp0mW1xWxY9WIZp9AQBmW03D7mxZoBmR5vffBAixgQFVWmE+K8PPIjupY62yTxjyp8qnzdx24KEDzb29eFmYcam+5f87Mt5KONDkiWWyRLay6kDO80ofOV5IYwPBM0Df5atQ7bxGNSTbH3V2Egf5Z4jhMOHmfp2lmS/sTWoDm5wslnh+/VNLWfh0OUune3kXkNEEQtGAzR5NAU86SoEDJGQBF0jWgVxEXsWuveAEIO07DtdDWXywv+I5ZtXFAwW1r6EhaSUv4ku5kaNoc0ioO+DB1iKzUmlUCvKIxZ+TLrphfnhwJjplXmISOchm9gu4Qc92kprrQWZEiW8ZGdz+o2rLzWq67UA2VxP4scCcOnvGCi 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 Fri, Apr 26, 2024 at 08:18:44AM -0700, Darrick J. Wong wrote: > 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? I don't think so. I think Christoph suggested to have it in the LBS series and see if MM folks can fix the issue upstream.[1] [1] https://www.spinics.net/lists/linux-xfs/msg83130.html > > 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 > > > >