Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6976695rwn; Tue, 13 Sep 2022 11:46:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR6RxXM6IRZtr6GgYvSS4vecmxyMkFgJGo6/ZIWfk5q0BwLCDlXurIo4WmpNBUSuXxIXV5J2 X-Received: by 2002:a17:907:72d6:b0:742:133b:42be with SMTP id du22-20020a17090772d600b00742133b42bemr21858711ejc.581.1663094779132; Tue, 13 Sep 2022 11:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663094779; cv=none; d=google.com; s=arc-20160816; b=1FXFlUt9B+eBRXc6yFsbWbWBneNwgr5WkCeEm167FyiNVpTz/zeNihmtoiSDIrNn7L qHMZBo5HGKdQibikZYkEC2CTFSDgH6Gpr6Q9S231Jzq+FydfjUVrVEb39NSkbwdRuFpv jCq0G4GoCACN8xp6w1KyfwmXPRHaVKBFg0EpP/14CoyeY1hhAyUdWULEBIYlaLpNTJBg eboLVYBFjVTXO22HnUA8U1A2RE6CDaHM2MFffI3US1XpiT3UIKWtw4xjyFXWC5G9/Y0x Zv2+AfOQtkWzyzRCyYvZ0d6Uah+VTso8twuMN+q7vAJ7Rybm4+I8eWt6metN+mZVPKiw W//Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cpmLQzxCgNdQMCvq0lnWzCraJ5MAUkkihNEafq2gk3w=; b=bkK3mTZTMezhevuog/RfYIrQHAZhoeCJVv3roqUYi4g1Qqb3mmIdAOp2Rja51DY95O rgDGABXqgvzs4ngd2rQeolv724bVd/pNkuJr+5D9cA6TDv/QUCb0p4K8xfL9Q5saKLfg QWS3smBahqLzikRcfBrYRvoOwHOAoAkmEz0D1TWEiwo1BF7WLM5Ea312ovpkozrUonBo gLw8MX31SkMvhuHDYpo8DRCy4MdoZ8k0KziFVGTk3MNUzqQ4OXGUJLU7T8dKNbCwpZey U33wRJ0Yu4jhs47il6XUXYRbnqYJEbNVzCRfbynjU+WOFeKpvUkMmVrOQ8aECmNhHGl8 V+lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oa67jNZT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a05640250d100b0044f1b69fbedsi11455820edb.338.2022.09.13.11.45.53; Tue, 13 Sep 2022 11:46:19 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oa67jNZT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232388AbiIMS12 (ORCPT + 99 others); Tue, 13 Sep 2022 14:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbiIMS0u (ORCPT ); Tue, 13 Sep 2022 14:26:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A87FE4505C for ; Tue, 13 Sep 2022 10:44:59 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 95FA161546 for ; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A331C433B5; Tue, 13 Sep 2022 17:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091098; bh=vJRpVbuRNEWxiwJhtSxeIniDUyu+JoVCpD8GHbjL3iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oa67jNZTl390H4yWs/1PtCmIDFSn0aIjc4wOuOXCSz50qUjEsDezOvqO40mBPvRBb JUqkSUSti/9RzAq9wIXpJ9bVY4V+KGnatsFN9xP62cAbc0b2R0l7y9232rPe/ehdi4 4diPT6xyF1GWkQxGDSKEvTnVsLMkMf4gIvMxMUWWFdAyzm9ad05f7365FDP5wyXYB2 t3XGfWvJlYcP231su+/HpzPF23arUhQ1wjp4YdxXPn6uta8Qb5L7ZheEYatfDBsBQb eNZJvCqQXW3ZwEqG21pchF6xekZzdau7IIzVqNBiLwPog0t5W/PxfU9QK/tgEdukdN zpRO4nyJerBOw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/22] mm/damon/core: factor out 'damos_quota' private fileds initialization Date: Tue, 13 Sep 2022 17:44:31 +0000 Message-Id: <20220913174449.50645-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The 'struct damos' creation function, 'damon_new_scheme()', does initialization of private fileds of 'struct damos_quota' in it. As its verbose and makes the function unnecessarily long, this commit factors it out to separate function. Signed-off-by: SeongJae Park --- mm/damon/core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 27e0c312f7a5..6767580c0a27 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -267,6 +267,19 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, return 0; } +/* initialize private fields of damos_quota and return the pointer */ +static struct damos_quota *damos_quota_init_priv(struct damos_quota *quota) +{ + quota->total_charged_sz = 0; + quota->total_charged_ns = 0; + quota->esz = 0; + quota->charged_sz = 0; + quota->charged_from = 0; + quota->charge_target_from = NULL; + quota->charge_addr_from = 0; + return quota; +} + struct damos *damon_new_scheme(struct damos_access_pattern *pattern, enum damos_action action, struct damos_quota *quota, struct damos_watermarks *wmarks) @@ -281,15 +294,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); - scheme->quota = *quota; - /* caller might not zero-initialized the private fileds */ - scheme->quota.total_charged_sz = 0; - scheme->quota.total_charged_ns = 0; - scheme->quota.esz = 0; - scheme->quota.charged_sz = 0; - scheme->quota.charged_from = 0; - scheme->quota.charge_target_from = NULL; - scheme->quota.charge_addr_from = 0; + scheme->quota = *(damos_quota_init_priv(quota)); scheme->wmarks = *wmarks; scheme->wmarks.activated = true; -- 2.25.1