From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D629F39E198 for ; Tue, 24 Feb 2026 14:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771944960; cv=none; b=JVqrv0dT/M4N7luW35ITb2n86zciRmMVw1Bsj/SNeJy7J5RmIKiWE+oUSPs3ihKFRqeAb9AyL7jn9xKyCAG/NFFaeWhT1muRBWxD44S7MF4aQwMJDnMtyv7W1R1Zxr9tW9yzozS7vtt8+sFz0gb3JMAGm3Gdbyuv8v9832X3b9E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771944960; c=relaxed/simple; bh=+DLuv7JiulTdryJ7AES8KMKTwVgtjpMXGf/4k1uBCVw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VVqb76zuG3XZu7h7V/A2obbmM88+AOLlDxh8paM6pB9+sAqGsyqFBgy/IjWKx2i1ogY960qNz6k9dqpfNC+RdXv9+q67onF9B7LdhURZ4vpj5r34jgWXVaJ87ZRYGwUpVfkad2vl4FnvR8C5/FdzTT/WSsGuyik5OnL63eoDfAQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WYhtcaRR; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WYhtcaRR" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-48371bb515eso69823525e9.1 for ; Tue, 24 Feb 2026 06:55:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771944957; x=1772549757; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=hftReuk+BjE4XIZFmQWrSGXEVWyYVhBcp3oc3KbKdkc=; b=WYhtcaRR6yrb/7kyYKnNCc6Cr9OlZnn4Rc41IoqocgdDirYDt4putx95tSMRfYq/WU 1TO3wLkimTgyu+5uQpJBZn6q+A1GmeCaG5Gix2J7xRINloGkksWt/q1Q7YJt8u7PVl/p AOQ4qD7ZYUpCDYo30Vszez1+DJkZWcd/lgnh7SeavaoyQO+scd248RE/0vqIY0sxxFuy 1NHDZOOQot0o416auCWpTSXyngnmcwUabGU/eujNjAKKppsS9Ufc/gZXQi571pm0Oc0G mi3moK3DXUAerlNb6vHf21c9zFAJmXW1QXdOccMxyxAnO7bLE1n4ERAE9k0hTxmFdFON gopw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771944957; x=1772549757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hftReuk+BjE4XIZFmQWrSGXEVWyYVhBcp3oc3KbKdkc=; b=DUTgdFQitRLURiDwCOM5UiefbBq2DK1/wsxAVJHnyjDLfMjQPhjUIwc40q8yk0eIqE PvLhFLPI+N3zstWdtotZ7mqmqhKJ8TtwXVc6P26b0CdGvup4EHV8BHRGbkVptKNIY/bC wYbC4oqO3bFV6FxCLljgG4IRTmISifTaP72ww6eenaDiO9/FlEXGD7C7REibIwS4Hx6g EADtel+kKFUMlnujJKfHD7FufAoLObTzxDFRStCD1ukFjrwvag324rJDH4Ev3sASzlY4 t+Cw0CvZ3SEoHe9QArlsQ1+GXmyZIwPxjaKEtSAebEDHS+AWWSA5eWI8jTyAyd+oUJpW avIA== X-Forwarded-Encrypted: i=1; AJvYcCWCWB5PrAHDBEW9oD5YRLjN5CqsphBEh0OHVwYEPFY0tZyWXDm6rADPSIvJnYcKPi6nwf+h5e9KYoXMr1k=@vger.kernel.org X-Gm-Message-State: AOJu0YyoHIpzRBJ7r4czqwX1RPMw2hTCyQgIgYgHmEO2tLevKAhuKUFt ZbDlLXV4jnGg2LIPXenr6TSkcUHECeKsX9XVg57B8CkEDgkn5+pctsE7NwFhK4Ei X-Gm-Gg: AZuq6aIDMKnZB8PGUj56j+qPyQRHCU9efGaA6tiuXOvxI0//xalWBt7aWeIKiHvAt2L WZLV5Xslg4sVFiPxezcSmL+fcpT0WZXt/DcAfdEWTs/MxoquY6/349WygPdiRHMiGPtMX5AJbGz FCH62hdq/+Y9ArUXcFGKRFBUcmJjmurkbeYu03FYOwyrl4smexm2DaoO/HOtJyfxFdh5E4mHiR5 4Trj63Ox2E7xG6ydSyOK0DrgeqoNVXz/NZCgAGxHs+bh6yCFubs6vnlcWIhEsD7SqVPEu+pvtyH 7dgqAHCOzDw6QOok1mToTBP51t7bOYuIUjSbJCWI0Zg3e8MvM+yG9RNh9YsytpaAZmjY1MBDOux qAjmVYEQluX/9iEJHG4fywXHG6/bCKGCVSLI1pKiCHQSee7xFOz03jij0PXC7msNkLYuNa2a4nf zBtBI5qNRYN1exYZWaKCRNUZgy8hGpZyAXA4aY33w6cxqdBqnuI+59nCMr2ndxwJJm X-Received: by 2002:a05:600c:8b2f:b0:483:4a95:66da with SMTP id 5b1f17b1804b1-483a95fc1c8mr217127005e9.13.1771944956953; Tue, 24 Feb 2026 06:55:56 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970bf9ff5sm28620552f8f.4.2026.02.24.06.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 06:55:56 -0800 (PST) Date: Tue, 24 Feb 2026 14:55:55 +0000 From: David Laight To: Qu Wenruo Cc: Miquel =?UTF-8?B?U2FiYXTDqSBTb2zDoA==?= , dsterba@suse.com, clm@fb.com, naohiro.aota@wdc.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kees@kernel.org Subject: Re: [PATCH] btrfs: replace kcalloc() calls to kzalloc_objs() Message-ID: <20260224145555.44a8096d@pumpkin> In-Reply-To: <69c16813-5ac1-4756-ad42-41b4275e6aee@gmx.com> References: <20260223234451.277369-1-mssola@mssola.com> <69c16813-5ac1-4756-ad42-41b4275e6aee@gmx.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 24 Feb 2026 15:07:10 +1030 Qu Wenruo wrote: > =E5=9C=A8 2026/2/24 10:14, Miquel Sabat=C3=A9 Sol=C3=A0 =E5=86=99=E9=81= =93: > > Commit 2932ba8d9c99 ("slab: Introduce kmalloc_obj() and family") > > introduced, among many others, the kzalloc_objs() helper, which has some > > benefits over kcalloc(). > >=20 > > Cc: Kees Cook > > Signed-off-by: Miquel Sabat=C3=A9 Sol=C3=A0 > > --- > > fs/btrfs/block-group.c | 2 +- > > fs/btrfs/raid56.c | 8 ++++---- > > fs/btrfs/tests/zoned-tests.c | 2 +- > > fs/btrfs/volumes.c | 6 ++---- > > fs/btrfs/zoned.c | 5 ++--- > > 5 files changed, 10 insertions(+), 13 deletions(-) > >=20 > > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c > > index 37bea850b3f0..8d85b4707690 100644 > > --- a/fs/btrfs/block-group.c > > +++ b/fs/btrfs/block-group.c > > @@ -2239,7 +2239,7 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_inf= o, u64 chunk_start, > > if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) > > io_stripe_size =3D btrfs_stripe_nr_to_offset(nr_data_stripes(map)); > > =20 > > - buf =3D kcalloc(map->num_stripes, sizeof(u64), GFP_NOFS); > > + buf =3D kzalloc_objs(*buf, map->num_stripes, GFP_NOFS); =20 >=20 > Not sure if we should use *buf for the type. >=20 > I still remember we had some bugs related to incorrect type usage. The global change really ought to have used u64 to add the type-check. Otherwise it will have added 'very hard to find' bugs in the very code it is trying to make better. Using *buf for the type might be a reasonable pattern for new code. David