From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B9AB720B20B; Tue, 12 Nov 2024 10:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731407320; cv=none; b=jvMvVH+U4owmo19FkOn5N21h0VwtmB2nvjHmkv+FfrbGee1BS+iAC6p9OAWG+qqDW586Rf0yaXN2ndfQnyNK3IWDy/zLYSVQicW/sr3wlJQKSy2ML/ZrHejWKElv+PYeeB3HzCwmh3YqCW1FsHyLNzxGaVM7fO8oWdPYcrnoxg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731407320; c=relaxed/simple; bh=QqvrpJ4T0XyECHPsJYk5f+4ffmyzDkkTWgZfZpkv+RI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gI3WXRSLOv+ybTNLTFEjp5y1Sx4uLFjwPKo7sJ6GVxuxpyWK+LtBWFbNV7Rvh30k98PpIZIqAaJppLr2zkNP8bcDlzbVtQce/SK5xQyCtgzp/npAMS4uP7yYlS3/5ZcnmCKAE0MNaEzaDSqDLbTV1KWEQU1i3/azPRtfjwm701k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=issYAlzj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="issYAlzj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 274C4C4CECD; Tue, 12 Nov 2024 10:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1731407320; bh=QqvrpJ4T0XyECHPsJYk5f+4ffmyzDkkTWgZfZpkv+RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=issYAlzjn7vZN581Pip9kRccM3KqIL/gF7lSPm4gBU0f5yCyPZbAjG/5lI6SkmdF4 SfBQ7y07WYH3iDgnkWKFaAsWPrSney//Z29aJH74mlbutxxhN80hx/6Bws82FHxk6P 2A612t4Z9nnsvNQQHoLMQAIdros7bAMB1UV4VOLE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qu Wenru , Naohiro Aota , Johannes Thumshirn , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 6.1 39/98] scsi: sd_zbc: Use kvzalloc() to allocate REPORT ZONES buffer Date: Tue, 12 Nov 2024 11:20:54 +0100 Message-ID: <20241112101845.763247331@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241112101844.263449965@linuxfoundation.org> References: <20241112101844.263449965@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Thumshirn [ Upstream commit 7ce3e6107103214d354a16729a472f588be60572 ] We have two reports of failed memory allocation in btrfs' code which is calling into report zones. Both of these reports have the following signature coming from __vmalloc_area_node(): kworker/u17:5: vmalloc error: size 0, failed to allocate pages, mode:0x10dc2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_NORETRY|__GFP_ZERO), nodemask=(null),cpuset=/,mems_allowed=0 Further debugging showed these where allocations of one sector (512 bytes) and at least one of the reporter's systems where low on memory, so going through the overhead of allocating a vm area failed. Switching the allocation from __vmalloc() to kvzalloc() avoids the overhead of vmalloc() on small allocations and succeeds. Note: the buffer is already freed using kvfree() so there's no need to adjust the free path. Cc: Qu Wenru Cc: Naohiro Aota Link: https://github.com/kdave/btrfs-progs/issues/779 Link: https://github.com/kdave/btrfs-progs/issues/915 Fixes: 23a50861adda ("scsi: sd_zbc: Cleanup sd_zbc_alloc_report_buffer()") Signed-off-by: Johannes Thumshirn Link: https://lore.kernel.org/r/20241030110253.11718-1-jth@kernel.org Reviewed-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/sd_zbc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 4c35b4a916355..4c78288ffa72f 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -216,8 +216,7 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp, bufsize = min_t(size_t, bufsize, queue_max_segments(q) << PAGE_SHIFT); while (bufsize >= SECTOR_SIZE) { - buf = __vmalloc(bufsize, - GFP_KERNEL | __GFP_ZERO | __GFP_NORETRY); + buf = kvzalloc(bufsize, GFP_KERNEL | __GFP_NORETRY); if (buf) { *buflen = bufsize; return buf; -- 2.43.0