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 95FC6C54EE9 for ; Tue, 20 Sep 2022 16:25:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2622940009; Tue, 20 Sep 2022 12:25:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD5E0940007; Tue, 20 Sep 2022 12:25:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7642940009; Tue, 20 Sep 2022 12:25:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A64D9940007 for ; Tue, 20 Sep 2022 12:25:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 731F016069F for ; Tue, 20 Sep 2022 16:25:52 +0000 (UTC) X-FDA: 79932990144.23.48708D1 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id C7DE416000D for ; Tue, 20 Sep 2022 16:25:49 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id BC290CE0FD8; Tue, 20 Sep 2022 16:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA8F7C433C1; Tue, 20 Sep 2022 16:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663691145; bh=C5q9Co4NCMuDWPDIy18NIrRPLs3YS6viqEBkhpcXokQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iiaGdfdNgWNjjYzCY6GxYsbSlhht8rThCwesmppTQNpo45yEPuKZT3YP+DH7EpmOV O7ecbuOfGcphHr6PzBdqARarUtJ6BqO/Z9PTEWTKTDiF6eqNxL90yP6ZFKAkbBNprM LnSN90j4IMgOj5LgOusVTodVjxIw0EJqmrw/u/vZt/enEjQJEqrlKdjD4eFPv2O/c6 3HQkFPLWZq71ARTjrJDa2xnHBp/RBtJUEgqgf9CKjIgEPEWH8+Trrb03JWaD6KXOwd FtMuad/w00HW3L2gOMgTmBhQsvCjRxMZJRb9uHAHP/K1BTcFok/Wg7GGPI+Whlqr19 JzjF+edCspwoQ== From: SeongJae Park To: haoxin Cc: SeongJae Park , akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 2/2] mm/damon/sysfs: use kzmalloc instead kmalloc to simplify codes Date: Tue, 20 Sep 2022 16:25:42 +0000 Message-Id: <20220920162542.52554-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <10f3f03d-e616-0619-cbe1-8515a3d7fc0e@linux.alibaba.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663691150; a=rsa-sha256; cv=none; b=ubF01IDon2XimXLQXhTQDbBAhlgKIb9oAct9xrYBjqifUVvqy55LIPX/yeJmmemGZOoPrp /8gVk0fGde6nGfU2TpxBrM/rsMD29NP3Y0nWPBTjEHaZzxQw+evIqLOtvM40Yb+/PcQUwx EUhwz5G1bjhJBC2qK8OJdmwGCoBZKmw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iiaGdfdN; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663691150; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Q815+++YaBPdABQFoYg5AVbjZj6F0PDWFxBQGmnCMZg=; b=Zegt0x3sjRuD7U9eSQIP3UehVCNmFLBgoxHkB1+hY04+Phdnvsds9Y2w1VCnkTSPfXx6yA LrSZoZwVSv4+uY6zs9HKqZVCHlxfulApE3ELkLgOFZxjiwoiQ9VYPo17dma4RhGFFOX7hK DLZx9pKd+nv8a1eF3GXGXY6Z0HmX+aE= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C7DE416000D X-Stat-Signature: awffia6dsq3jqn8pkcemn88wbeafz1z1 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iiaGdfdN; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-HE-Tag: 1663691149-661472 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: Hi Xin, On Tue, 20 Sep 2022 09:58:41 +0800 haoxin wrote: > > 在 2022/9/20 上午1:22, SeongJae Park 写道: > > On Mon, 19 Sep 2022 23:12:01 +0800 Xin Hao wrote: > > > >> In damon_sysfs_access_pattern_alloc() adn damon_sysfs_attrs_alloc(), > >> we can use kzmalloc to alloc instance of the related structs, This makes > >> the function code much cleaner. > > This definitely makes the code cleaner, thank you. But, the initial intent of > > the code is to initialize the fiedls that really need to be initialized at the > > point, for the efficiency and also for making it clear which field is needed to > > be initialized to what value here. It's also intended to make readers wonder > > about where and how the remaining fields are initialized. > > Maybe the other func like damon_sysfs_kdamonds_alloc() also need to do > like this, you can see it return directly by > > kzalloc. > > static struct damon_sysfs_kdamonds *damon_sysfs_kdamonds_alloc(void) > { > return kzalloc(sizeof(struct damon_sysfs_kdamonds), > GFP_KERNEL); > } In this case, all the fields of the struct need to be initialized as zero. That's why we use kzalloc() there. Of course, my opinion is not a static and concrete rule, but changing mind. And obviously everyone makes many mistakes and DAMON code has many rooms for improvement. I really appreciate for your greatful efforts for that. But, at least in this case, I think it doesn't really need the change at the moment, IMHO. Thanks, SJ [...]