Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4878153rwb; Tue, 20 Sep 2022 23:08:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SblxUSO16T6UcQllMJoheI4Iexvx+cFnzpaPgHD6zwW0lW7luN9PKoQPj+Vhk4E98C/L1 X-Received: by 2002:a17:906:770d:b0:73c:a08f:593c with SMTP id q13-20020a170906770d00b0073ca08f593cmr20343400ejm.182.1663740485555; Tue, 20 Sep 2022 23:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663740485; cv=none; d=google.com; s=arc-20160816; b=uZ14/tjeN2RLL312LAwwbtOAm6S3WFOsUvMjxCKMIkWuLjWBqSqXKYb0PvIBmQADPL ovswcgJlSYrF0i6Z+RpYW1yb19KfUh1uFT40agglnc82sbVA9oai+O3qKDHzppfX0zVS a7wcGA7zrngxKRWaLIdZ9o1WCPHWJgP2XhTufJkGBB6q3A1OEWAzZtY7lf5bT+VKfQCT 1dCm8u13ZTES1XJkIH+BvHhRyJ975qe1IQRsDFjgIrzNr/JKaLoTy7xFKNWzbmCGbyj0 MDgegagk/wbO0X8WwYRhqVpchMT3b0ardtGCOudAiWy/scx5Pk3RJ+5esBKs+S6xpWSm FspQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=CbtFEWkCfMa/mTH5Rce1fGF7acsLQSY/DmwIMnKE9sU=; b=l7YiCM7eJwTck5y3Fw7L2xTcPT9pGxyEwlb2DAFqP6nxSfT3Ljb4dbpmOVq1rjYJkF kOYHNjBtvT2aYZJb4J9rVulmif/h37BwPp9cu+foKMgPbxmTVghzqnUA4u/g2tVUD40g o7oJ6CPstbSsiETeZZrnIUMOJR2C4PVeATLiJnv+55CYdK+/MuCBCOPiIfp5N+wmCkZl 8bTHjsCldRPJVKbs3epKdCA8QpfBLriAhYRQq5MQDLIy0lrYkn0ZJrbvZ9Ui/0cSYVud 3oSx0uUIzv0/yEpXNo8qdwihU79RdF6U0iqm2VbEuuqHaGP3smj3+wYPDO/AyyiAq8cX ScCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f25-20020a50d559000000b0043bf15dc4d2si1396755edj.131.2022.09.20.23.07.39; Tue, 20 Sep 2022 23:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiIUFUd (ORCPT + 99 others); Wed, 21 Sep 2022 01:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbiIUFU1 (ORCPT ); Wed, 21 Sep 2022 01:20:27 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21D2E24F17 for ; Tue, 20 Sep 2022 22:20:25 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VQMWsxm_1663737621; Received: from 30.240.97.89(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VQMWsxm_1663737621) by smtp.aliyun-inc.com; Wed, 21 Sep 2022 13:20:22 +0800 Message-ID: <09ddb8f0-9ea3-2dd0-fa77-430ff3380f85@linux.alibaba.com> Date: Wed, 21 Sep 2022 13:20:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v1 2/2] mm/damon/sysfs: use kzmalloc instead kmalloc to simplify codes To: SeongJae Park Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220920162542.52554-1-sj@kernel.org> From: haoxin In-Reply-To: <20220920162542.52554-1-sj@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/9/21 上午12:25, SeongJae Park 写道: > 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. Understand your concern,  at least, there is no point in simplifying the code too mush if we are ignoring its readability. > 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 > > [...]