Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1007570lqa; Sun, 28 Apr 2024 14:07:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxbXjHGBOgMGy5ZBNdtVIaQjegi93DNui7lu2Ql/hxGyQPeOQtAn1iC9qSC7Yoi0oUHqiSlUa3mAQvnjLto7bJjqssIp3iiybotSUdWw== X-Google-Smtp-Source: AGHT+IGMkGjKi6oi07Dt7+7FfQ7JRnmKBtpdScOT8T4z8HblDJqyaDoMpxftz6X6ADOLho3/Caz1 X-Received: by 2002:a05:6214:19c5:b0:699:2274:b229 with SMTP id j5-20020a05621419c500b006992274b229mr10386651qvc.14.1714338420017; Sun, 28 Apr 2024 14:07:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714338420; cv=pass; d=google.com; s=arc-20160816; b=n+TBXUPksfqLjulXL0E3Th5+VcOxDiDKGf3PIoXwYsqk1VO5agvGf7wQnvYFPf6M5q Szu7umP/lEVUMbE6SUhBtH561H6+3/BxxVyblgqjo72nVj9FXiEsWJ3guvr1QQW9Zvp2 H6iGChKDOhOck0uHuLNlxSX3l2ef6LFUUtOs6ViG218H4mrZVJMOaoIiGyd8IzuklgHc L3zYwT6RnL1gqps+HstD3wNLJo3t7USlVmDVqREcOae9lRkE/NrjDCv322luvs73mlKU KhGOYLQ2z0CeFjxnXrgveoD2smBYE4w3KIBfoUPblXlteDidIakVZzUZRVH3hqqHocwA qxIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7yxstpfnkO3d6ouRSTqsWyefS+SUn2WUJo5CNc78Tx4=; fh=Sol5vukNReDoZS77O1NnZEzbp0Rrw7U8X+swY6F2anY=; b=Y7YZigihcQfYc6PM+IlGUdNZDRw964yN23IMDKbgoyqSfydNWgq9Y054aqPcd6lGid sbewz0X3tIrYKUDUk+TxUhWKyIsGNeWK+dHG8yjiJqtnGaxS2PnEk6k+840eVeLX5XJh hum1lnficHWtSG/r9RC82u/b4Q9HZNA5rRwwiFTVoe6JjSaQd9ZDimH5l43qMHgb3BQX savIF3d/OVXdMeNiggewchry2G8ohOIpylYYr17dpbf/RUl2ENYYmMz8TeWhAqs2kOs0 h7jb+1vvHEs7u0zbFk+3cfkM6PWtBZXvQ12rZUiE5UZ3pgtjnHQuRX7QJS80hCFLavs+ tXiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=hWtochC6; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-161569-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161569-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id iw10-20020a0562140f2a00b006a0cb8130e9si1605006qvb.256.2024.04.28.14.06.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 14:07:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161569-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=hWtochC6; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-161569-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161569-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AEFD51C20815 for ; Sun, 28 Apr 2024 21:06:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C30D4B664; Sun, 28 Apr 2024 21:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="hWtochC6" Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0A4C389; Sun, 28 Apr 2024 21:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714338406; cv=none; b=H40kCCaNxlfLHGzmaWnVL0h6Jy2yFfzFMPNCPGN/eqFQQDttFOuc4KnrSJr3I5pMwsPZR7i0i5/rlfK1lslhzq11EUwB8reJGRB1fcKRHh8ZBZ4LQ1S5T+QVjVSoU8KrJ/kxiDCMCFMYFOoaTZE6DR6xBVzhUUZpsUGFqMI8mj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714338406; c=relaxed/simple; bh=qVoyDKva76pyHWAnpgXS+CNDH7/QfVHQPMFgQ33N1Q8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=V+ova6HX/JBsOisqX76mgniQQFtaBbNlW7dQQC1rUBT465szq79H6KdFBgVwpAQgPHAvrrTAzzVGlUncboWlw8ksKDXmUvHfK6nTKNn5wNWwlgd7EANcV9Utkr7qv2t4lJ+LLwdQX7+qptnQoSXQr993dPjEp5y7JVgTH4euXFs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=hWtochC6; arc=none smtp.client-ip=80.241.56.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240426151844.GH360919@frogsfrogsfrogs> 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 > > > >