From patchwork Mon Oct 24 20:49:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682870wru; Mon, 24 Oct 2022 15:33:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jA9/mGyTQ1aCKUPbNDtCp+f4KEsJEktHnt/bvjRMaaUA0/BfeGiRJq5j2nJgSnw57wHRJ X-Received: by 2002:a17:907:a4a:b0:77b:c1b2:479a with SMTP id be10-20020a1709070a4a00b0077bc1b2479amr27173794ejc.109.1666650787909; Mon, 24 Oct 2022 15:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650787; cv=none; d=google.com; s=arc-20160816; b=UQb1EH/7OsGp/2d/b4uYV2v9SUnSYEZHKSEUQI1nE/grmRC3VBtSjwE+lVEZdPmtEx 3YzmbbyjSiP405WnE46dQVWKWN7ntyqDFhHwyBn7BbPQxmAE72qXNeiS4ykEUapX9ptc ohoiYIhL/9uHP6L15D+G+N3fn5clgtjGa4EJM2b+l5C8hyL8On0YkKd2sTbb87Sd/xJN HQkbTNzXlannumBsQ0aUl6P9qidHS8q+vojJOIHAKD/s0Mhnc7ofb8a5csd6ieb2gQge Bn4YCiLh3rrxKEfNHFUSgpZOwrfbcmdxQ5o91U7r3e3iT+o+EWSXL3KP2aZvmEPmSAox UzOQ== 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=LvMHpXZEdN3oQBqUmWsHlEJHre7AMc1kY7dAqIHInM8=; b=Tx60IchukFSV0mpcRIkfdzBXxYjsx+v51x8UX/0DyLVPfeBrWNZuK4J5Ix0cuUkd+/ ftbFDug/nFOVYj7s0yOapYTT/bd+AHXL4kL96JPZ22/o0vFXo16TMpGl2gNtonHAbdAo iq4Jserz1goGoi3+2trJfkTwvRV2VeE6J6kYPAdHH3gmVw7lVPWnJISTDvnuZvtdL0Es 1Y1efGBSPjOSM4sR/u9UscOeUPNDRoDNbWdi87Sk919CxcL8Odrk3Ti5swABj6x7IzRC TF2PGxI0i5SBDnzOSliF8LXnuFxGtOzM1Mfnii1OkcN5mu9Er/b30AWN9WmBJSLa7rW7 xiSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uKMGy0G6; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a05640240cb00b00458e43471d5si1088723edb.614.2022.10.24.15.32.44; Mon, 24 Oct 2022 15:33:07 -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=uKMGy0G6; 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 S230457AbiJXW2t (ORCPT + 99 others); Mon, 24 Oct 2022 18:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231160AbiJXW2X (ORCPT ); Mon, 24 Oct 2022 18:28:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D32232738 for ; Mon, 24 Oct 2022 13:50:33 -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 32DAD6156A for ; Mon, 24 Oct 2022 20:49:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 310FFC43470; Mon, 24 Oct 2022 20:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644565; bh=oUwwKx4MXojkoEQqGNX/HEaiCbrgYpcKgdZZJ/EkGWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uKMGy0G6jcaGd0zTpR25Gix/DSt03DjhqKeRS6R6ysGdjXdWs+7H8xeUlFIeCJL0h 1ZxJ0p4nufcgHwt0jkA1sdbhlmfhB8o9N7kOr7bjj4DkqYvDkvg5crypPti+m4h56x oF0ltzUpLlBpduDIF+VhIqEuEq5nCMFUJaEYGAIIdhdAt8LrvPpr7NjW6q+mFA5/Hy Nw3fO5k/IHl+lF7taJMHNRKazCaOw/prWaaR9srfa4y9bed5HaKoN+8Wian6/QXFlz wPeboMDnqzyY/Yul8HhGh+0cM5fGMK0fr43YGRhBHZlPVPlVPuY/PTj5SfIkl7G+7T XFkTH3jGPpLdw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/11] mm/damon/core: split out DAMOS-charged region skip logic into a new function Date: Mon, 24 Oct 2022 20:49:09 +0000 Message-Id: <20221024204919.18524-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610016593235158?= X-GMAIL-MSGID: =?utf-8?q?1747610016593235158?= The DAMOS action applying function, 'damon_do_apply_schemes()', is quite long and not so simple. Split out the already quota-charged region skip code, which is not a small amount of simple code, into a new function with some comments for better readability. Signed-off-by: SeongJae Park --- mm/damon/core.c | 96 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 31 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 36d098d06c55..06b50ede9cc6 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -694,6 +694,67 @@ static bool damos_valid_target(struct damon_ctx *c, struct damon_target *t, return c->ops.get_scheme_score(c, t, r, s) >= s->quota.min_score; } +/* + * damos_skip_charged_region() - Check if the given region or starting part of + * it is already charged for the DAMOS quota. + * @t: The target of the region. + * @rp: The pointer to the region. + * @s: The scheme to be applied. + * + * If a quota of a scheme has exceeded in a quota charge window, the scheme's + * action would applied to only a part of the target access pattern fulfilling + * regions. To avoid applying the scheme action to only already applied + * regions, DAMON skips applying the scheme action to the regions that charged + * in the previous charge window. + * + * This function checks if a given region should be skipped or not for the + * reason. If only the starting part of the region has previously charged, + * this function splits the region into two so that the second one covers the + * area that not charged in the previous charge widnow and saves the second + * region in *rp and returns false, so that the caller can apply DAMON action + * to the second one. + * + * Return: true if the region should be entirely skipped, false otherwise. + */ +static bool damos_skip_charged_region(struct damon_target *t, + struct damon_region **rp, struct damos *s) +{ + struct damon_region *r = *rp; + struct damos_quota *quota = &s->quota; + unsigned long sz_to_skip; + + /* Skip previously charged regions */ + if (quota->charge_target_from) { + if (t != quota->charge_target_from) + return true; + if (r == damon_last_region(t)) { + quota->charge_target_from = NULL; + quota->charge_addr_from = 0; + return true; + } + if (quota->charge_addr_from && + r->ar.end <= quota->charge_addr_from) + return true; + + if (quota->charge_addr_from && r->ar.start < + quota->charge_addr_from) { + sz_to_skip = ALIGN_DOWN(quota->charge_addr_from - + r->ar.start, DAMON_MIN_REGION); + if (!sz_to_skip) { + if (damon_sz_region(r) <= DAMON_MIN_REGION) + return true; + sz_to_skip = DAMON_MIN_REGION; + } + damon_split_region_at(t, r, sz_to_skip); + r = damon_next_region(r); + *rp = r; + } + quota->charge_target_from = NULL; + quota->charge_addr_from = 0; + } + return false; +} + static void damon_do_apply_schemes(struct damon_ctx *c, struct damon_target *t, struct damon_region *r) @@ -702,7 +763,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c, damon_for_each_scheme(s, c) { struct damos_quota *quota = &s->quota; - unsigned long sz = damon_sz_region(r); + unsigned long sz; struct timespec64 begin, end; unsigned long sz_applied = 0; @@ -713,41 +774,14 @@ static void damon_do_apply_schemes(struct damon_ctx *c, if (quota->esz && quota->charged_sz >= quota->esz) continue; - /* Skip previously charged regions */ - if (quota->charge_target_from) { - if (t != quota->charge_target_from) - continue; - if (r == damon_last_region(t)) { - quota->charge_target_from = NULL; - quota->charge_addr_from = 0; - continue; - } - if (quota->charge_addr_from && - r->ar.end <= quota->charge_addr_from) - continue; - - if (quota->charge_addr_from && r->ar.start < - quota->charge_addr_from) { - sz = ALIGN_DOWN(quota->charge_addr_from - - r->ar.start, DAMON_MIN_REGION); - if (!sz) { - if (damon_sz_region(r) <= - DAMON_MIN_REGION) - continue; - sz = DAMON_MIN_REGION; - } - damon_split_region_at(t, r, sz); - r = damon_next_region(r); - sz = damon_sz_region(r); - } - quota->charge_target_from = NULL; - quota->charge_addr_from = 0; - } + if (damos_skip_charged_region(t, &r, s)) + continue; if (!damos_valid_target(c, t, r, s)) continue; /* Apply the scheme */ + sz = damon_sz_region(r); if (c->ops.apply_scheme) { if (quota->esz && quota->charged_sz + sz > quota->esz) { From patchwork Mon Oct 24 20:49:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682847wru; Mon, 24 Oct 2022 15:33:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qqjO1jz16D4SzCgIvfHruBM5Tz6/LJchDVR8qZ+aSbMC0r4t9m4LprGGclxThyC6y2qbP X-Received: by 2002:a17:907:2c72:b0:7a4:a4b4:9fcb with SMTP id ib18-20020a1709072c7200b007a4a4b49fcbmr9041882ejc.403.1666650781490; Mon, 24 Oct 2022 15:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650781; cv=none; d=google.com; s=arc-20160816; b=HCQlYKRgy2OXaUUMptOPGLh7onwsygQoSBxShFCtXegO/G3MDkWTWyEAK/k3cp0nK1 l7vaOytW2mfvaf6EVaOOWCkLUmGg0AEwvjA+LiLDe6/ouqXYGZiIXqMzVnkXtt8KUp9q g1tVsP6e32TkbQ/YpRdcNupO9KS7P64z45KTd90mSFNG4vFMW5VkQZOzm5fIPREPPUa5 iHGjdeU5Gz75mkS1TFkQZTESreli8vFRsG0pJOj///ob9301EGoHNrRhuQZtfFwR/DYJ UCR04VYlu7idMj/pMLd8AMA7FFz8e+ispaPdxPtEmBTbe6HHAETowR66UGI6NsuqJLHE A8aQ== 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=6IDw96NAPiqSJva+D9kDbJFGy3oGiwtYEJtWrgb2Vxw=; b=U4cwB2Q9Jq08IgBywXjAMIplIGSDhFLPkUnV+zlZXzAz9rht8Hsbay+dxg6EwqWAkJ 6uVVyXmtPkI4rcf4fu9psxnSKOJeXFFOqbG8NlxGKGqsheX4Z/tq37Su4rusC35yjFrT 1hrVfD+I6NBWHwJTMwT+AO7jKyFrxegRK5GoSlEVadpFRWNQCVAhAtIwu3h+agPduGNa FqfPUXLOO2mxt1Ag4uobDqWkYpzowCauhLJY9zquG+n1tpa9OGorXlD9p6mHvgV2JeRu uEDnjWLUWSU+qMFhyidV1fas7/S3ugTgWvyAUJZrizO0hKD1fmyFTabwDK2n5QIRRb+N 2aiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k2JE8BUc; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a170906950100b007830f14fffesi748308ejx.375.2022.10.24.15.32.38; Mon, 24 Oct 2022 15:33:01 -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=k2JE8BUc; 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 S230245AbiJXW2o (ORCPT + 99 others); Mon, 24 Oct 2022 18:28:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbiJXW2U (ORCPT ); Mon, 24 Oct 2022 18:28:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDAE4E09B6 for ; Mon, 24 Oct 2022 13:50:31 -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 C6908615AF for ; Mon, 24 Oct 2022 20:49:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C64AEC433B5; Mon, 24 Oct 2022 20:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644566; bh=6gkbB+R8KOY+SdO75f4hZZPeo2cZLZlMbp4Q5xwVX/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2JE8BUc9CDzQp8FHIo00S+bYyfg76YGiWY77fybUWWKCKCkKvkBlapFcVAkJdT21 OyxQuZehDJkhV+fP/ZKHNJWb13Rey5FR6GVzdWCAY4xyrPPAIW+b80ttkTMwmpK2xu ke0PoM0FOADZxag6l+3amaoXlIviMs5WIcrJORGgk4VIXyAPBnphiALkNMpTOg1Oo1 LJ7U8LoA3eQ7peUhonZAUQAYxYnDw6fU1OyOyV89AaLor7qP2Vd/lbkd2ph5hYdjfZ 1dTpra6wHkod4UAhw4OzrSI5lszp2jrdqOeLeUDl0EsiTc9F1Y1kBZ+49hmQp5zuPH y7FhKrdRFSINg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/11] mm/damon/core: split damos application logic into a new function Date: Mon, 24 Oct 2022 20:49:10 +0000 Message-Id: <20221024204919.18524-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610009796325462?= X-GMAIL-MSGID: =?utf-8?q?1747610009796325462?= The DAMOS action applying function, 'damon_do_apply_schemes()', is still long and not easy to read. Split out the code for applying a single action to a single region into a new function for better readability. Signed-off-by: SeongJae Park --- mm/damon/core.c | 73 ++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 06b50ede9cc6..c1a912bc46ae 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -755,6 +755,44 @@ static bool damos_skip_charged_region(struct damon_target *t, return false; } +static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, + struct damon_region *r, struct damos *s) +{ + struct damos_quota *quota = &s->quota; + unsigned long sz = damon_sz_region(r); + struct timespec64 begin, end; + unsigned long sz_applied = 0; + + if (c->ops.apply_scheme) { + if (quota->esz && quota->charged_sz + sz > quota->esz) { + sz = ALIGN_DOWN(quota->esz - quota->charged_sz, + DAMON_MIN_REGION); + if (!sz) + goto update_stat; + damon_split_region_at(t, r, sz); + } + ktime_get_coarse_ts64(&begin); + sz_applied = c->ops.apply_scheme(c, t, r, s); + ktime_get_coarse_ts64(&end); + quota->total_charged_ns += timespec64_to_ns(&end) - + timespec64_to_ns(&begin); + quota->charged_sz += sz; + if (quota->esz && quota->charged_sz >= quota->esz) { + quota->charge_target_from = t; + quota->charge_addr_from = r->ar.end + 1; + } + } + if (s->action != DAMOS_STAT) + r->age = 0; + +update_stat: + s->stat.nr_tried++; + s->stat.sz_tried += sz; + if (sz_applied) + s->stat.nr_applied++; + s->stat.sz_applied += sz_applied; +} + static void damon_do_apply_schemes(struct damon_ctx *c, struct damon_target *t, struct damon_region *r) @@ -763,9 +801,6 @@ static void damon_do_apply_schemes(struct damon_ctx *c, damon_for_each_scheme(s, c) { struct damos_quota *quota = &s->quota; - unsigned long sz; - struct timespec64 begin, end; - unsigned long sz_applied = 0; if (!s->wmarks.activated) continue; @@ -780,37 +815,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c, if (!damos_valid_target(c, t, r, s)) continue; - /* Apply the scheme */ - sz = damon_sz_region(r); - if (c->ops.apply_scheme) { - if (quota->esz && - quota->charged_sz + sz > quota->esz) { - sz = ALIGN_DOWN(quota->esz - quota->charged_sz, - DAMON_MIN_REGION); - if (!sz) - goto update_stat; - damon_split_region_at(t, r, sz); - } - ktime_get_coarse_ts64(&begin); - sz_applied = c->ops.apply_scheme(c, t, r, s); - ktime_get_coarse_ts64(&end); - quota->total_charged_ns += timespec64_to_ns(&end) - - timespec64_to_ns(&begin); - quota->charged_sz += sz; - if (quota->esz && quota->charged_sz >= quota->esz) { - quota->charge_target_from = t; - quota->charge_addr_from = r->ar.end + 1; - } - } - if (s->action != DAMOS_STAT) - r->age = 0; - -update_stat: - s->stat.nr_tried++; - s->stat.sz_tried += sz; - if (sz_applied) - s->stat.nr_applied++; - s->stat.sz_applied += sz_applied; + damos_apply_scheme(c, t, r, s); } } From patchwork Mon Oct 24 20:49:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682910wru; Mon, 24 Oct 2022 15:33:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5njJkDukJ0PZSN2bwU2NGpDMKBowF69anSZku+J9ZK4v76C7rsnr649vMZa1dSlAG7Dgou X-Received: by 2002:a05:6402:3548:b0:45d:6506:990a with SMTP id f8-20020a056402354800b0045d6506990amr32905750edd.218.1666650795612; Mon, 24 Oct 2022 15:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650795; cv=none; d=google.com; s=arc-20160816; b=m+/rPITfp7PAZrzWkKMH5pQXwPZCaTGVwQ+jYW5F97jHMXrej5fa8/Q76tOCR8CDK3 6cd+h3yCa4wHD+XuTFKqX4VjeQ13ylFOeBphaddNc1mm6OWf3KC0xWXK5ocLgWAA/Lh4 Xn8i183oWzwwi4G0nRtMH1s3j1caS3abVwpxYblj3VJxAgCmFR+jnjVWsPGN6qa58jpf njGNrBk5sfAhr1Ew89w36zkU4MCZDNBqx/VpHwC75FF2rU4Z+OPOafqUcEa2p5bh0srz 2rA/DiDBdV+OM7K5scKt3QhkNJCNRbAX+rCnWQPPGRPWMDlxsrNGhf1+DBWzFnPvTEJB BtAw== 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=yUphVaM1VYW9wh/A0/sAzOrAe+7BWF4145DldAvvZ7w=; b=vnEtTpLD/vZPT7teCmjRYNBDdFq2bcvo0c4ZJYeIj+XTsZNkthpfx4RIbo/+pDjI62 8ixtEbApjpRZ1goGhzDD+aRmw30MIz/oNkCTHgcJCkzX+TfWwwq9m3M0tMfIAYDrL8Wj sX7Qi4ifX0loB810OMAXgOayJj2W3Avya2fmlJUmC0A5ZbZ1i4c03JtdNqADZw8dxacG ar7H66hTQnQp0J2bku2ubKyCVKh5tOHPU0pUkzk190rtia9xO49u5Gw7K8ChWoVpiUct JzA0oMfMfO+cJQaSewonlW8gbOWh2kdRbEACNtUOBzmWVLOGIS7LYsSa55Q1ysAwWRs6 93Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FyrbHG8N; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp14-20020a1709071b0e00b00787d0dfe70csi887462ejc.981.2022.10.24.15.32.52; Mon, 24 Oct 2022 15:33:15 -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=FyrbHG8N; 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 S231444AbiJXW2y (ORCPT + 99 others); Mon, 24 Oct 2022 18:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbiJXW2Z (ORCPT ); Mon, 24 Oct 2022 18:28:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99047CC81B for ; Mon, 24 Oct 2022 13:50:41 -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 5689F615B1 for ; Mon, 24 Oct 2022 20:49:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 675DBC433C1; Mon, 24 Oct 2022 20:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644566; bh=QMVnOfjAwBASqqnveYH7trvPbLLGctoJVzDXAjo2/8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FyrbHG8NuKtPFlidl5Tt0VxBwZ8AofU8nM31c9QRt1YL5zkER4eT2t+bWyQFKhWKT wgBvSYeXCu/SEO9HBwRLFHFnApLFi4fK3uolj7j1l3IYTVqMbJk9KgSUV3eycqs+4a KC2hn7UvUBfb8XgCKTXaMLzPZiQlY0bnvM9geXmAKP5qtIgFwfRH0WCeNUfMxxVou5 cwKA6edu910iaXY07Tg93RDb/xublLsnERZAR3rBuWGnbAN69bAVk9SIA7ZSVASkRu YFpx/0viFcOmQn1UAp4gY+geKqFA3VTlxr90CWiODhwqD/L8xsvKxyTks3Ye3twMom DLxObNmljhd7Q== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/11] mm/damon/core: split out scheme stat update logic into a new function Date: Mon, 24 Oct 2022 20:49:11 +0000 Message-Id: <20221024204919.18524-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610024585096376?= X-GMAIL-MSGID: =?utf-8?q?1747610024585096376?= The function for applying a given DAMON scheme action to a given DAMON region, 'damos_apply_scheme()' is not quite short. Make it better to read by splitting out the stat update logic into a new function. Signed-off-by: SeongJae Park --- mm/damon/core.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index c1a912bc46ae..3a810c6e26bc 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -755,6 +755,16 @@ static bool damos_skip_charged_region(struct damon_target *t, return false; } +static void damos_update_stat(struct damos *s, + unsigned long sz_tried, unsigned long sz_applied) +{ + s->stat.nr_tried++; + s->stat.sz_tried += sz_tried; + if (sz_applied) + s->stat.nr_applied++; + s->stat.sz_applied += sz_applied; +} + static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, struct damon_region *r, struct damos *s) { @@ -786,11 +796,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, r->age = 0; update_stat: - s->stat.nr_tried++; - s->stat.sz_tried += sz; - if (sz_applied) - s->stat.nr_applied++; - s->stat.sz_applied += sz_applied; + damos_update_stat(s, sz, sz_applied); } static void damon_do_apply_schemes(struct damon_ctx *c, From patchwork Mon Oct 24 20:49:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp682927wru; Mon, 24 Oct 2022 15:33:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61W0oGUkuRbLC/nehkrrdT6HmIeOtHRu91CTqKNHESh2dvccYSMZNhlKw2U+gZo8yvAmJz X-Received: by 2002:a17:907:7607:b0:78d:66e8:c746 with SMTP id jx7-20020a170907760700b0078d66e8c746mr29937158ejc.220.1666650798592; Mon, 24 Oct 2022 15:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650798; cv=none; d=google.com; s=arc-20160816; b=tIkLXUJiLGi++/c/twIPYd8w7LpbAR/Eyl41vjlpXCLX5MmCdLVMO0gXfyTh84/saP DHSIDnOgYYIP/JIH3AvEpZCsIKAPxweW7HKCY1ZF4GaSMwBrWU3AC2iYwODuxUPabRz3 3gsUhKaiJoezMyFsIOwCEliYe/f1mzda1pWxx2ESmEQKsSyY3jivtvP8UsJ0hHSIOiNh 8LT+cyhnQPeG7twIO8fYKu+x5ayTByBp1iF+PoDdOZHfjivSfXWgjSdGnLo6kVEX7KA8 v/uu2WJqhY3JEF4piUWjZcRXS8wBQtyKvqNdF/JFVt6zE7ufkGjTfA0iMovkpMdDcJrm H8cw== 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=VcTQr7jD9MTx+tgBKr2WrTJarvzJlUpBZKclONSTMuE=; b=jrLw8LpvPT1F4tOEcW1zovJW5N/DeGJsajabWkS2tQxSjyid3IsFfkC9ndXC+cEEU+ EMTdIGpmb2H030hiHPsmVUGKUpfUvtU4HkS9paxdljjmYCohgVPXTSUZswlo/wibQZT0 hf371PDyMY490wZzK1gsHCwXda83+Yo9a6txKBDEFyeZkmfct5F1svYLyG3P78XIzh60 atmYHaNaPHGWTM9JSk/bOhyNW1At2rLV0UCDMjWKOcP1e0ne6IcJUtBSal/vktGBH87F jbTt1tS8l4f4mPUFgL5/K2JedRaEst3GkVG5Cltz+hIvsNslGRE8/rXm6bAHO2El0xHW yUJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T00bDNA9; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cf14-20020a0564020b8e00b00461dbe292e0si775835edb.270.2022.10.24.15.32.54; Mon, 24 Oct 2022 15:33:18 -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=T00bDNA9; 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 S231526AbiJXW3D (ORCPT + 99 others); Mon, 24 Oct 2022 18:29:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231161AbiJXW2Z (ORCPT ); Mon, 24 Oct 2022 18:28:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170CD857D5 for ; Mon, 24 Oct 2022 13:50:40 -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 ams.source.kernel.org (Postfix) with ESMTPS id AAE8AB81219 for ; Mon, 24 Oct 2022 20:49:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F11B0C4347C; Mon, 24 Oct 2022 20:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644567; bh=dahNXHHpseZsI9Nv09e0SATucdrpYMf1XoLkXw98+8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T00bDNA9EM4Dfry8euvfrqLlGlmknH7wo3tkSrHReFZBihrsinlKvK2L6eYULPQ71 CEhWRzbBenBjIaZ4xywgYNePssRTPlLGv/TTZf2YahCGZ60rbcYuw6AALjOMWfphHY HltEqsgeCd1Q2xSuMHVmc+QmHO8G4GK2irj3nbqXCjkypNOKBzV3T9OpuJJU2Qz4zs q/0wlkJgkK3VcA8eTX7mBjy1aVzt+LXhrDDU0SF4KiUt6htMt6fa0XPXmcPrsu5ma2 5ZXYR6syB+bRWAl1LEBPvVsA5Ld3jN8MhWF+d3+jxfZgkGEDDO1IGv+5OCvKqa7Wgq VD4zGhLaNXxtw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/11] mm/damon/core: split out scheme quota adjustment logic into a new function Date: Mon, 24 Oct 2022 20:49:12 +0000 Message-Id: <20221024204919.18524-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610027371268935?= X-GMAIL-MSGID: =?utf-8?q?1747610027371268935?= DAMOS quota adjustment logic in 'kdamond_apply_schemes()', has some amount of code, and the logic is not so straightforward. Split it out to a new function for better readability. Signed-off-by: SeongJae Park --- mm/damon/core.c | 91 ++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 3a810c6e26bc..80d5937fe337 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -848,59 +848,64 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->esz = esz; } -static void kdamond_apply_schemes(struct damon_ctx *c) +static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) { + struct damos_quota *quota = &s->quota; struct damon_target *t; - struct damon_region *r, *next_r; - struct damos *s; + struct damon_region *r; + unsigned long cumulated_sz; + unsigned int score, max_score = 0; - damon_for_each_scheme(s, c) { - struct damos_quota *quota = &s->quota; - unsigned long cumulated_sz; - unsigned int score, max_score = 0; + if (!quota->ms && !quota->sz) + return; - if (!s->wmarks.activated) - continue; + /* New charge window starts */ + if (time_after_eq(jiffies, quota->charged_from + + msecs_to_jiffies(quota->reset_interval))) { + if (quota->esz && quota->charged_sz >= quota->esz) + s->stat.qt_exceeds++; + quota->total_charged_sz += quota->charged_sz; + quota->charged_from = jiffies; + quota->charged_sz = 0; + damos_set_effective_quota(quota); + } - if (!quota->ms && !quota->sz) - continue; + if (!c->ops.get_scheme_score) + return; - /* New charge window starts */ - if (time_after_eq(jiffies, quota->charged_from + - msecs_to_jiffies( - quota->reset_interval))) { - if (quota->esz && quota->charged_sz >= quota->esz) - s->stat.qt_exceeds++; - quota->total_charged_sz += quota->charged_sz; - quota->charged_from = jiffies; - quota->charged_sz = 0; - damos_set_effective_quota(quota); + /* Fill up the score histogram */ + memset(quota->histogram, 0, sizeof(quota->histogram)); + damon_for_each_target(t, c) { + damon_for_each_region(r, t) { + if (!__damos_valid_target(r, s)) + continue; + score = c->ops.get_scheme_score(c, t, r, s); + quota->histogram[score] += damon_sz_region(r); + if (score > max_score) + max_score = score; } + } - if (!c->ops.get_scheme_score) - continue; + /* Set the min score limit */ + for (cumulated_sz = 0, score = max_score; ; score--) { + cumulated_sz += quota->histogram[score]; + if (cumulated_sz >= quota->esz || !score) + break; + } + quota->min_score = score; +} - /* Fill up the score histogram */ - memset(quota->histogram, 0, sizeof(quota->histogram)); - damon_for_each_target(t, c) { - damon_for_each_region(r, t) { - if (!__damos_valid_target(r, s)) - continue; - score = c->ops.get_scheme_score( - c, t, r, s); - quota->histogram[score] += damon_sz_region(r); - if (score > max_score) - max_score = score; - } - } +static void kdamond_apply_schemes(struct damon_ctx *c) +{ + struct damon_target *t; + struct damon_region *r, *next_r; + struct damos *s; - /* Set the min score limit */ - for (cumulated_sz = 0, score = max_score; ; score--) { - cumulated_sz += quota->histogram[score]; - if (cumulated_sz >= quota->esz || !score) - break; - } - quota->min_score = score; + damon_for_each_scheme(s, c) { + if (!s->wmarks.activated) + continue; + + damos_adjust_quota(c, s); } damon_for_each_target(t, c) { From patchwork Mon Oct 24 20:49:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683906wru; Mon, 24 Oct 2022 15:36:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM54eD2xQ3npru9EaekLj1kJeUNfWzl5at3nhPToj9qZDE/+4AyrWkVtemDgQIQ2hwHqge09 X-Received: by 2002:a17:907:3e85:b0:73d:60cc:5d06 with SMTP id hs5-20020a1709073e8500b0073d60cc5d06mr30529120ejc.722.1666650966030; Mon, 24 Oct 2022 15:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650966; cv=none; d=google.com; s=arc-20160816; b=cNAA3e+kJkhxGA3/U0r9zqxThwwqXwrmzapt4m/ZxRvMgKyrFK8Pbz7IS0d+Sej6aL d3zZNAcc7G+bylkJDdgEmiQhGATnKDjDLaRfR0LaSe9NgLZoA+zgtW+0C0VzYrl9gaCW 3FQPk5nQKCkpF95hHq61TCC7vb4TfFT1R0PhA+/ojuGhfmccVVn+PX2zmP1diEJQDowp KxlBXX1NyHwgv+iWe+SfulA902LcnL2FmaX8y+ZUl24Y68gIdo/FpkcldjDmF5ql6J4O LxTGCKvzKBS8SqUd+lohN2jcHaLfHLjnRgeYsg0S/K2TSXQGGjBEeW4ydgjYPpqRdH4H w6/w== 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=7n+YCXhSActcFsJQM+bMjwhqitqXcBT33KamBQXu4Hs=; b=jEusl3VfSgIikJpM8coXH/jY1zvjgqvRZuKDkL3Mdc69I4aJ1L7GpDHpcK40a3BXMB UJDyOrWcATvzN7COmYsEYIruXzRVKyVelio/7dV3SDkNdK0R5RHkQzeSgQVX9wl+CRo2 hiUAJmnFRQH5O930rSCC3WJQ3Cg/KSKe5G64Jp10wLPa4/RY+GQlvCaR6Fxyf8LDKm0g y39dG3oWWH708vUCWr5QW6ihLi/Kss9UtbqXNCaUH7IsNnsS2HztiDUYrClSE0zudJXf R58obIhr9t0OaL7okswcxhzH2H//hfXxqQrOJiL0I7OHZ8OhyFW86khB/gLDdPdm6XzX q+ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YDdPWy+h; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020a50d687000000b00459039258b2si1007619edi.289.2022.10.24.15.35.42; Mon, 24 Oct 2022 15:36:06 -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=YDdPWy+h; 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 S230313AbiJXW3t (ORCPT + 99 others); Mon, 24 Oct 2022 18:29:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbiJXW3O (ORCPT ); Mon, 24 Oct 2022 18:29:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C954319CF9 for ; Mon, 24 Oct 2022 13:51:25 -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 81606615A8 for ; Mon, 24 Oct 2022 20:49:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94284C43470; Mon, 24 Oct 2022 20:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644568; bh=sv1BrnKGZiPaDlM88kZTZVyO+ljEIr4/QgXhQUY8YPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YDdPWy+hk/dA6bO1JvIxHQEsUadklBlUEuvRHSxp8TUizL8iK7lQE+1JK5yx3EiBJ DIY+QpAeB1tdtqIcxsIwmwDIWQjNvZ9nwue1mo4qgY/I5jWfHjH56yu7xsSaYmgGb4 PQiwORUnIyXxcyX7K9EGsZ5wIZaBqrDaXiTF4QTavo3eoUVdhk7sjt5c5jOTcvsTLC SMcKFOiF8eqBqt7LICtCoXlPK5r0ai0fjcWL/O+XsGrZI0Ytwmxk4HbEOAsDeeDQPt TRaZn2P/ZnGqu/bRmAxiTM+OvV6/f2fnCMfE6qG0nbrjgqs+H9ICKjlRuHQSNbYGwS 3I03m0XNVTL7w== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/11] mm/damon/sysfs: use damon_addr_range for regions' start and end values Date: Mon, 24 Oct 2022 20:49:13 +0000 Message-Id: <20221024204919.18524-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610203843479820?= X-GMAIL-MSGID: =?utf-8?q?1747610203843479820?= DAMON has a struct for each address range but DAMON sysfs interface is using the low type (unsigned long) for storing the start and end addresses of regions. Use the dedicated struct for better type safety. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 9f1219a67e3f..b9183063bfea 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1062,13 +1062,11 @@ static struct kobj_type damon_sysfs_schemes_ktype = { struct damon_sysfs_region { struct kobject kobj; - unsigned long start; - unsigned long end; + struct damon_addr_range ar; }; static struct damon_sysfs_region *damon_sysfs_region_alloc( - unsigned long start, - unsigned long end) + struct damon_addr_range ar) { struct damon_sysfs_region *region = kmalloc(sizeof(*region), GFP_KERNEL); @@ -1076,8 +1074,7 @@ static struct damon_sysfs_region *damon_sysfs_region_alloc( if (!region) return NULL; region->kobj = (struct kobject){}; - region->start = start; - region->end = end; + region->ar = ar; return region; } @@ -1087,7 +1084,7 @@ static ssize_t start_show(struct kobject *kobj, struct kobj_attribute *attr, struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - return sysfs_emit(buf, "%lu\n", region->start); + return sysfs_emit(buf, "%lu\n", region->ar.start); } static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr, @@ -1095,7 +1092,7 @@ static ssize_t start_store(struct kobject *kobj, struct kobj_attribute *attr, { struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - int err = kstrtoul(buf, 0, ®ion->start); + int err = kstrtoul(buf, 0, ®ion->ar.start); return err ? err : count; } @@ -1106,7 +1103,7 @@ static ssize_t end_show(struct kobject *kobj, struct kobj_attribute *attr, struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - return sysfs_emit(buf, "%lu\n", region->end); + return sysfs_emit(buf, "%lu\n", region->ar.end); } static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr, @@ -1114,7 +1111,7 @@ static ssize_t end_store(struct kobject *kobj, struct kobj_attribute *attr, { struct damon_sysfs_region *region = container_of(kobj, struct damon_sysfs_region, kobj); - int err = kstrtoul(buf, 0, ®ion->end); + int err = kstrtoul(buf, 0, ®ion->ar.end); return err ? err : count; } @@ -1187,7 +1184,7 @@ static int damon_sysfs_regions_add_dirs(struct damon_sysfs_regions *regions, regions->regions_arr = regions_arr; for (i = 0; i < nr_regions; i++) { - region = damon_sysfs_region_alloc(0, 0); + region = damon_sysfs_region_alloc((struct damon_addr_range){}); if (!region) { damon_sysfs_regions_rm_dirs(regions); return -ENOMEM; @@ -2147,11 +2144,11 @@ static int damon_sysfs_set_regions(struct damon_target *t, struct damon_sysfs_region *sys_region = sysfs_regions->regions_arr[i]; - if (sys_region->start > sys_region->end) + if (sys_region->ar.start > sys_region->ar.end) goto out; - ranges[i].start = sys_region->start; - ranges[i].end = sys_region->end; + ranges[i].start = sys_region->ar.start; + ranges[i].end = sys_region->ar.end; if (i == 0) continue; if (ranges[i - 1].end > ranges[i].start) From patchwork Mon Oct 24 20:49:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683888wru; Mon, 24 Oct 2022 15:36:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FxsuNdmO1tuIRD2hdQPNDuVIKcqP/e1uP75e9l/14tpzMBFgG469il9EwCeOBuMSt4mpQ X-Received: by 2002:a17:907:70b:b0:740:ef93:2ffb with SMTP id xb11-20020a170907070b00b00740ef932ffbmr29128636ejb.93.1666650962213; Mon, 24 Oct 2022 15:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650962; cv=none; d=google.com; s=arc-20160816; b=mDz+g9lNIJz6RZdLB46/w5Ztemo9FrdKJxlO3arhgWn07gMp/24dl5Zg0KBN66i92X ftO4WGJ6N/JYUddOio8ruriZgVF6jC0xYw4i6k/gOdjG1FOTm13xx919hG8bosxrb4eQ iS4gU50G76RM/d7+Yuj6fUhJXXom7+Vi+diDIm/K3vj4daedxD83691q9fhVrcEcK06r L6LuXSr/1lpXGskWnIf7mIJTZaPhaIYSLgNUj+7DT/xS1hnJs7ESRoYSJlJnr9Tk2qAM 3rlWonIGS+LXdkRVw/sbdYS9eI2JjHMgJP1UXKQzOD/4ZnMd/WSiKMzFwd6vp1uVlEP+ HnJw== 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=03ly8U/KAwHOuI8XWF1KHkMMfsjMuz58ZNQJDMju10o=; b=mr90G6ZMuhnsX/SfPy3lt8a8rjK7AgwVrTpEY47GZ4gZVaJmS4c1m2qCqxx8GkL0Tw M/0jZ1yC/YCNkKvG2DESismCzOifyso6lo+N64GQmLNC0yv8BpJdVvy44BhkDaHO5LXC dQp8C6eqwhP1eRvNEK3gY+tuyoBOB7ncfebSQH7OQ1wD+XRoEqh5AIeT98oFCdje5noT SHZWpmFFzyltXdCV1hhZmKOMpJaO3tN0G/j/eVh53/zwq9k85guvSEM3qG9rZEzLn0LP w1Vywr92Grpp4h+eCj+k2TapzG7CP9oYnOP23BeGU0j/Rx8eKJN49i1Q3aQ1mQUgKe2n lILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G0PNJwF7; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cf14-20020a0564020b8e00b00461dbe292e0si775835edb.270.2022.10.24.15.35.38; Mon, 24 Oct 2022 15:36:02 -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=G0PNJwF7; 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 S230493AbiJXWdj (ORCPT + 99 others); Mon, 24 Oct 2022 18:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbiJXWdT (ORCPT ); Mon, 24 Oct 2022 18:33:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78AF12BE880 for ; Mon, 24 Oct 2022 13:56:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id D3772B811FB for ; Mon, 24 Oct 2022 20:49:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C5A2C433D6; Mon, 24 Oct 2022 20:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644568; bh=ujSci3Jr9yWO8XdHXzr/zi1RpAlYDD3yaad0xsGDwtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0PNJwF7F8B6wDCT8U5OvUuUzVBgp8YQ/xYp56NtYF3J+apq8tV363lbDS/dAVE9x fmE1KhGzme+66U40xnPxhCiGER08YnmCVpFOOoXzMNwJdsHg9XkhE0h2IglBKku8Qk 0R3GZqSNZtFaMKpOjz9jv3aamgzvzty7b1BBMqBiUTBM5Z3QCKDU2LJ1lVnuJfzih4 YiMPbVNMnUXZTngRymS02lmsG8cD41erv/DtQA2mKokmw5y+4FXwKDV4hBH/tUKLJY 2YNKfkUPrm/R4hseLEskL/AinkQdMCyRdNeV3Gza0l5JxjrTscQ6MhU4BaaSFDNiXW zkY/9xpZ6LDRg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/11] mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc() Date: Mon, 24 Oct 2022 20:49:14 +0000 Message-Id: <20221024204919.18524-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610199453836543?= X-GMAIL-MSGID: =?utf-8?q?1747610199453836543?= 'damon_sysfs_region_alloc()' is always called with zero-filled 'struct damon_addr_range', because the start and end addresses should set by users. Remove unnecessary parameters of the function and simplify the body by using 'kzalloc()'. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index b9183063bfea..e8bd7367d15b 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1065,17 +1065,9 @@ struct damon_sysfs_region { struct damon_addr_range ar; }; -static struct damon_sysfs_region *damon_sysfs_region_alloc( - struct damon_addr_range ar) +static struct damon_sysfs_region *damon_sysfs_region_alloc(void) { - struct damon_sysfs_region *region = kmalloc(sizeof(*region), - GFP_KERNEL); - - if (!region) - return NULL; - region->kobj = (struct kobject){}; - region->ar = ar; - return region; + return kzalloc(sizeof(struct damon_sysfs_region), GFP_KERNEL); } static ssize_t start_show(struct kobject *kobj, struct kobj_attribute *attr, @@ -1184,7 +1176,7 @@ static int damon_sysfs_regions_add_dirs(struct damon_sysfs_regions *regions, regions->regions_arr = regions_arr; for (i = 0; i < nr_regions; i++) { - region = damon_sysfs_region_alloc((struct damon_addr_range){}); + region = damon_sysfs_region_alloc(); if (!region) { damon_sysfs_regions_rm_dirs(regions); return -ENOMEM; From patchwork Mon Oct 24 20:49:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp686347wru; Mon, 24 Oct 2022 15:43:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6aTjM5KhuvdPBKH9b/3qLmMVIqXmBa+usfPj73GJwzXS+iKvEgI0aiap1j3VCRq35w19ks X-Received: by 2002:a17:907:2c74:b0:7a1:d333:f214 with SMTP id ib20-20020a1709072c7400b007a1d333f214mr11630135ejc.14.1666651393018; Mon, 24 Oct 2022 15:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666651393; cv=none; d=google.com; s=arc-20160816; b=Ah4zmW0xcxyA0SO7eoBwp9gHxnQ102NmXANjrgAkUU5k6pezp33sjBWdZcexRa1Ccp iVLjVDKOFxDD9amvYqLGDwRk/A+7E4MXAh2sswXLHAo3qY34Aq2ANRJy9Rw4ywvax6of t/27p+uuKKK4WtsspAKdw7Ce0f1Noq44h18kFj8b9+fDz9GLWvp+vftZP7bBO6yas1te RmI+iXfEyibOzWXqeFrdCqmSHihZZwm5OmkobuTz63bxi3ZOEdURu8TKTfi0qeWyssev Owztg/DfoBZr9TV9tfaFzPyme5eKPhQNQwiX0J2UfEyjDIAHGybWSVsz7LKGKXyEzHjI d6uQ== 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=8gnVqw+0ufpRZWu3rYTVACNYbATkDeUVVJn8K0t45/I=; b=QM4jRc1H539P8PvQIfCY68Rjzf2W2QXEJoHoZWIlwTUwVMGnLhGa0w+X9gY4I08Jtw pCTr7/KYe9ZbtwetTwvwG86Hp9Qsu03S2ALtFF2scKTvfbdA2UJlXQFAO38G8Jp+i/9f Bp0a4mReqUlpdCqxDzTXju3Jp6g4ifiXcTiZR6wfZRw1b4nVOtq9GGBtt4AdEMEQzuOw N517AkAfOLCv0iiSnAzjTNkEsACFBEYd0Sx5WODqa7ZmDVLGtgEandoOjczGsd5Yw0ou 8Co7GiMjmMIxveTxgBhG8QRbC+EfxporiPqEIcCkdpRh/Y0mB/JlgYA8mTjH4AOt2BKa sWkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HSzy9SJ0; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp26-20020a1709073e1a00b0073d8b93700csi1084848ejc.165.2022.10.24.15.42.48; Mon, 24 Oct 2022 15:43:13 -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=HSzy9SJ0; 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 S229562AbiJXWld (ORCPT + 99 others); Mon, 24 Oct 2022 18:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231585AbiJXWkQ (ORCPT ); Mon, 24 Oct 2022 18:40:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A422B65E8 for ; Mon, 24 Oct 2022 14:04:04 -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 AAB4B615B9 for ; Mon, 24 Oct 2022 20:49:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5339C433B5; Mon, 24 Oct 2022 20:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644569; bh=ToGxVn5DgkZtjVMi4IGaA+ZXlJgYyh7RCq47o6e6Bdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HSzy9SJ0dwZ69SDES5dYIVzSTUayn4yv8SDwn3IaJf/ABaUHGdh4f4jGjqv8cVWzD Yk1PyK4+OE9EJR8TcwLDAy5+nqT82hdT9S+/vCMlHuorkE+Y1Ns7qRd/qBDpGujUDI F4m5W5o4vy96+Q5vmBGLGAfpXnhWVfm+0CJBW3T1cuvf+PqqJEkNTUlgTj+FqjObDN 2GXiHaGWExkIdPnsJMCeyD6rEWMdOzlwdbs7G3neaoWXRWxUe/1ysjGra8pf1JbCl5 aRs/0AOYQpQSLSZHjsnUo/UYIkO/S5rSW4D0ELTlfXd2xzLORWwAqUEbhLfm8/jbPQ tUx0sed/3Olqw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH 07/11] mm/damon/sysfs: move sysfs_lock to common module Date: Mon, 24 Oct 2022 20:49:15 +0000 Message-Id: <20221024204919.18524-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610651009008817?= X-GMAIL-MSGID: =?utf-8?q?1747610651009008817?= DAMON sysfs interface is implemented in a single file, sysfs.c, which has about 2,800 lines of code. As the interface is hierarchical and some of the code can be reused by different hierarchies, it would make more sense to split out the implementation into common parts and different parts in multiple files. As the beginning of the work, create files for common code and move the global mutex for directories modifications protection into the new file. Signed-off-by: SeongJae Park --- mm/damon/Makefile | 2 +- mm/damon/sysfs-common.c | 11 +++++++++++ mm/damon/sysfs-common.h | 11 +++++++++++ mm/damon/sysfs.c | 4 +--- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 mm/damon/sysfs-common.c create mode 100644 mm/damon/sysfs-common.h diff --git a/mm/damon/Makefile b/mm/damon/Makefile index 3e6b8ad73858..f8d535a6253b 100644 --- a/mm/damon/Makefile +++ b/mm/damon/Makefile @@ -3,7 +3,7 @@ obj-y := core.o obj-$(CONFIG_DAMON_VADDR) += ops-common.o vaddr.o obj-$(CONFIG_DAMON_PADDR) += ops-common.o paddr.o -obj-$(CONFIG_DAMON_SYSFS) += sysfs.o +obj-$(CONFIG_DAMON_SYSFS) += sysfs-common.o sysfs.o obj-$(CONFIG_DAMON_DBGFS) += dbgfs.o obj-$(CONFIG_DAMON_RECLAIM) += reclaim.o obj-$(CONFIG_DAMON_LRU_SORT) += lru_sort.o diff --git a/mm/damon/sysfs-common.c b/mm/damon/sysfs-common.c new file mode 100644 index 000000000000..9dc743868d5b --- /dev/null +++ b/mm/damon/sysfs-common.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Common Primitives for DAMON Sysfs Interface + * + * Author: SeongJae Park + */ + +#include "sysfs-common.h" + +DEFINE_MUTEX(damon_sysfs_lock); + diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h new file mode 100644 index 000000000000..745a918b94f5 --- /dev/null +++ b/mm/damon/sysfs-common.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Common Primitives for DAMON Sysfs Interface + * + * Author: SeongJae Park + */ + +#include +#include + +extern struct mutex damon_sysfs_lock; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index e8bd7367d15b..0f3f06d8dae7 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -5,13 +5,11 @@ * Copyright (c) 2022 SeongJae Park */ -#include -#include #include #include #include -static DEFINE_MUTEX(damon_sysfs_lock); +#include "sysfs-common.h" /* * unsigned long range directory From patchwork Mon Oct 24 20:49:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683189wru; Mon, 24 Oct 2022 15:34:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4uYNlfZxfhztrk4pDzTJpyAtGGLdXrS/veOlpY0utyc/aTFodN5N1a00w3g6JZoWfixd9g X-Received: by 2002:a17:906:974f:b0:7aa:f705:e580 with SMTP id o15-20020a170906974f00b007aaf705e580mr2851360ejy.530.1666650845500; Mon, 24 Oct 2022 15:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650845; cv=none; d=google.com; s=arc-20160816; b=nNSRz9L3D//OEFPvuKc2IKccJMjoOjgq0/iV9l9AXMTclKWxcd+mrUZfWDuQAjnuFj Rmd54Wqd5fjNW/p7XciMLdhvxISrvH70PrwJ1z8GaG2K43Ixyn0EbBNlk6JFPW+WBXH9 zOrjcDCcydsl5/LOMi63YnC3MtOctVYf5LnVRC/RqEdSzCWeYGjgo8j4i2GW32OyO6a/ xOWhQ5iGRldCsRVJ0pymDRso7hpTZ1n7qgKehresXOuLziRRSHuNtMZQJI3z2LdTXs1Z Lq34D3L1VhqvaOjY3XaVgxRA/Q1vVyLM2Q+M6PiUwtN27hDHSvVZfHkSCTVibpXsuOK1 VahQ== 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=Bpp+mgs6T3vQx9VGv8u094mKTae+w/hydalOkPe08bM=; b=JIrtYwqBIwt56UU1b/+GTjbdtSJo+Npe8Jz3dPe5VavGyGwn6YrSEJoT7p+8kx3nMW 1y35CIEXXOq0WAVN1e4O/rpAYu8CcKjLdoo+EARNpd85vDNbPZuYARpWqc/KZkGZ+HIZ BlKfSAO2/PE/5it0bVjN69RrwRN6YmU2/HdYfInftK1URGIVj/+0YBSjEadw03oKrul1 SaL1devDhtbay9LvUbObzHIa4K0h+kErx3+ohWVwxvSw5mX4+K2sXeBLE/YGNR3ECRTj EBJ6jQ7gtBrRTLd86wNqFcEQm7God6RB+azQrKxSuhjNNiEK+XrVkpLSIMe/i4T3npeq vakA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G6WZBASY; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a056402280a00b00451e1aae675si1105457ede.547.2022.10.24.15.33.41; Mon, 24 Oct 2022 15:34: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G6WZBASY; 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 S230513AbiJXWam (ORCPT + 99 others); Mon, 24 Oct 2022 18:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231535AbiJXWaO (ORCPT ); Mon, 24 Oct 2022 18:30:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF7CB6E2EC for ; Mon, 24 Oct 2022 13:52:39 -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 DFA8C615B3 for ; Mon, 24 Oct 2022 20:49:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E0F5C433C1; Mon, 24 Oct 2022 20:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644569; bh=zkSKxd+aFM4wLLzA3DhfvQt2mZE0FdxT9KFkAovv2q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G6WZBASYLD6LklC/+lqeZoDfG3dGQIzRLumccHTMO4T7Q5mINGCI4MIgGb2B0XqhT 1NFEYa+1n12cb74Dg3VHsDmrhWsQPW2QOb8aIS/NQ9qxx+vLNRqeyDN2xi75Omjov1 oToMe521lNjikNFXIh0rt82zJXngxjovF3SSWwZDJ8UzVuc8yIBdlOt8tgk3BiVeB9 ZCt2PNnfHBZqzAxrxHxb2bIa7JRuZA4O8gVk3m4FyTSyi7rH0uLhiLIu/+aN4igQlr Orb4Ju7MGgTATAU84n36nZY4tv4zqMrn8Rs76A+rg7UpvX7X2Wq2vKi93zy0khlsY+ 1m7BXfV5hTJzA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/11] mm/damon/sysfs: move unsigned long range directory to common module Date: Mon, 24 Oct 2022 20:49:16 +0000 Message-Id: <20221024204919.18524-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610077130094303?= X-GMAIL-MSGID: =?utf-8?q?1747610077130094303?= The implementation of unsigned long type range directories can be reused by multiple DAMON sysfs directories including those for DAMON-based Operation Schemes and the range of number of monitoring regions. Move the code into the files for DAMON sysfs common logics. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.c | 96 ++++++++++++++++++++++++++++++++++++++ mm/damon/sysfs-common.h | 13 ++++++ mm/damon/sysfs.c | 100 ---------------------------------------- 3 files changed, 109 insertions(+), 100 deletions(-) diff --git a/mm/damon/sysfs-common.c b/mm/damon/sysfs-common.c index 9dc743868d5b..52bebf242f74 100644 --- a/mm/damon/sysfs-common.c +++ b/mm/damon/sysfs-common.c @@ -5,7 +5,103 @@ * Author: SeongJae Park */ +#include + #include "sysfs-common.h" DEFINE_MUTEX(damon_sysfs_lock); +/* + * unsigned long range directory + */ + +struct damon_sysfs_ul_range *damon_sysfs_ul_range_alloc( + unsigned long min, + unsigned long max) +{ + struct damon_sysfs_ul_range *range = kmalloc(sizeof(*range), + GFP_KERNEL); + + if (!range) + return NULL; + range->kobj = (struct kobject){}; + range->min = min; + range->max = max; + + return range; +} + +static ssize_t min_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct damon_sysfs_ul_range *range = container_of(kobj, + struct damon_sysfs_ul_range, kobj); + + return sysfs_emit(buf, "%lu\n", range->min); +} + +static ssize_t min_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct damon_sysfs_ul_range *range = container_of(kobj, + struct damon_sysfs_ul_range, kobj); + unsigned long min; + int err; + + err = kstrtoul(buf, 0, &min); + if (err) + return err; + + range->min = min; + return count; +} + +static ssize_t max_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct damon_sysfs_ul_range *range = container_of(kobj, + struct damon_sysfs_ul_range, kobj); + + return sysfs_emit(buf, "%lu\n", range->max); +} + +static ssize_t max_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct damon_sysfs_ul_range *range = container_of(kobj, + struct damon_sysfs_ul_range, kobj); + unsigned long max; + int err; + + err = kstrtoul(buf, 0, &max); + if (err) + return err; + + range->max = max; + return count; +} + +void damon_sysfs_ul_range_release(struct kobject *kobj) +{ + kfree(container_of(kobj, struct damon_sysfs_ul_range, kobj)); +} + +static struct kobj_attribute damon_sysfs_ul_range_min_attr = + __ATTR_RW_MODE(min, 0600); + +static struct kobj_attribute damon_sysfs_ul_range_max_attr = + __ATTR_RW_MODE(max, 0600); + +static struct attribute *damon_sysfs_ul_range_attrs[] = { + &damon_sysfs_ul_range_min_attr.attr, + &damon_sysfs_ul_range_max_attr.attr, + NULL, +}; +ATTRIBUTE_GROUPS(damon_sysfs_ul_range); + +struct kobj_type damon_sysfs_ul_range_ktype = { + .release = damon_sysfs_ul_range_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damon_sysfs_ul_range_groups, +}; + diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index 745a918b94f5..56e6a99e353b 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -9,3 +9,16 @@ #include extern struct mutex damon_sysfs_lock; + +struct damon_sysfs_ul_range { + struct kobject kobj; + unsigned long min; + unsigned long max; +}; + +struct damon_sysfs_ul_range *damon_sysfs_ul_range_alloc( + unsigned long min, + unsigned long max); +void damon_sysfs_ul_range_release(struct kobject *kobj); + +extern struct kobj_type damon_sysfs_ul_range_ktype; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 0f3f06d8dae7..129743292e17 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -11,106 +11,6 @@ #include "sysfs-common.h" -/* - * unsigned long range directory - */ - -struct damon_sysfs_ul_range { - struct kobject kobj; - unsigned long min; - unsigned long max; -}; - -static struct damon_sysfs_ul_range *damon_sysfs_ul_range_alloc( - unsigned long min, - unsigned long max) -{ - struct damon_sysfs_ul_range *range = kmalloc(sizeof(*range), - GFP_KERNEL); - - if (!range) - return NULL; - range->kobj = (struct kobject){}; - range->min = min; - range->max = max; - - return range; -} - -static ssize_t min_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - struct damon_sysfs_ul_range *range = container_of(kobj, - struct damon_sysfs_ul_range, kobj); - - return sysfs_emit(buf, "%lu\n", range->min); -} - -static ssize_t min_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct damon_sysfs_ul_range *range = container_of(kobj, - struct damon_sysfs_ul_range, kobj); - unsigned long min; - int err; - - err = kstrtoul(buf, 0, &min); - if (err) - return err; - - range->min = min; - return count; -} - -static ssize_t max_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - struct damon_sysfs_ul_range *range = container_of(kobj, - struct damon_sysfs_ul_range, kobj); - - return sysfs_emit(buf, "%lu\n", range->max); -} - -static ssize_t max_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct damon_sysfs_ul_range *range = container_of(kobj, - struct damon_sysfs_ul_range, kobj); - unsigned long max; - int err; - - err = kstrtoul(buf, 0, &max); - if (err) - return err; - - range->max = max; - return count; -} - -static void damon_sysfs_ul_range_release(struct kobject *kobj) -{ - kfree(container_of(kobj, struct damon_sysfs_ul_range, kobj)); -} - -static struct kobj_attribute damon_sysfs_ul_range_min_attr = - __ATTR_RW_MODE(min, 0600); - -static struct kobj_attribute damon_sysfs_ul_range_max_attr = - __ATTR_RW_MODE(max, 0600); - -static struct attribute *damon_sysfs_ul_range_attrs[] = { - &damon_sysfs_ul_range_min_attr.attr, - &damon_sysfs_ul_range_max_attr.attr, - NULL, -}; -ATTRIBUTE_GROUPS(damon_sysfs_ul_range); - -static struct kobj_type damon_sysfs_ul_range_ktype = { - .release = damon_sysfs_ul_range_release, - .sysfs_ops = &kobj_sysfs_ops, - .default_groups = damon_sysfs_ul_range_groups, -}; - /* * schemes/stats directory */ From patchwork Mon Oct 24 20:49:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683774wru; Mon, 24 Oct 2022 15:35:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67FgauZkEjQG8BBBXaCKqD6hKAE9Uja5I57kaa1qQKSgqDpLy6Q2XsIPW6wN3Aj6Ehuzsp X-Received: by 2002:a05:6402:410:b0:451:ea13:4ed7 with SMTP id q16-20020a056402041000b00451ea134ed7mr34112751edv.262.1666650945002; Mon, 24 Oct 2022 15:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650944; cv=none; d=google.com; s=arc-20160816; b=WgYifc+ekosUBLJr+S5IoSNXFduCi6lZt0/Qfv2+PS7oPfVgEGLu6F/JaJDMsITUT1 Xpgmwo9/eLEUjoCXnD3qhymYyya6WKcHGmb8fzPmtt19pVZUqYN6RUvz+v2owjCX5Gws 3evRc+mjJ+7FsmDNW1FivwqG5gI+WH6sGiC5Fn7BxZXAtMVvJEF6Tfs5kjfeIII1LzBL t/8gAx8mg6XaI3YJmVI2ZJ0KzeHW4p1H6PVwqgIPasQXeSSHiVQgBGh/pfY9t8ZjdBmr 93Yd+Z6792PI1rxBF9YLVfl75BJzQZbRXbqfX7pnkA6jTm/R/dV3Rrsx3NUEfxzvoa8i H9IA== 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=teuLmkvrqYh7YfKqBTEJkBAA5R2vUCoFSJoNDkGPoso=; b=Xn9EvvzLZWsUbmGH2r0JPRPX0NC+NzdYflqojaRwJ7qH7VGEkzY23Mv2xaVsRqjD0s TuyiIPRBBxEfb0Q8BQXA+B1OIAydLVKwMQNH/pYM5gO9PPK7C8pSEBd1Y40KVCl0JXz7 KFvWpZu9VKWD/nh2bPSpoM2LysoJar9enevcefLyxnPUz3rvIJ1PEUNugTe+XPFUjME3 WU9N2EDhxCVd6WakB7nH8zaE1vbNCI+ELjHEUXyICQi9BY4jGRXiVYo/QeIdGiFrCOsW bYCWRl1WOjwqVLpM5zqgYjtubgx1B7vt4sK++o/bj8Bz4Lcp/i3bdiREOB96t0kkr14J xu4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bQ1l016H; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg44-20020a170907a42c00b00734b2821879si1000420ejc.898.2022.10.24.15.35.20; Mon, 24 Oct 2022 15:35:44 -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=bQ1l016H; 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 S230292AbiJXW3h (ORCPT + 99 others); Mon, 24 Oct 2022 18:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230483AbiJXW2q (ORCPT ); Mon, 24 Oct 2022 18:28:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0B4FAE860 for ; Mon, 24 Oct 2022 13:51:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8740FB81217 for ; Mon, 24 Oct 2022 20:49:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4913C4347C; Mon, 24 Oct 2022 20:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644570; bh=vYg+3rru4Qa0elGvOm6kAk7xSDdvfn1bfJkC8oPWZ2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bQ1l016Hbl7kpxCKXRQ/Z3qblmevoS9Ww3RXT6D9e356Ljbw+lu0lL/Jhj5DbNpA/ BrtFYRBI8Tt9Xq5U6mi+Lt+Huq/Kuw7SELZlrHhN27rd5Pd03mWp131nTHhumzSqrc lq75y4ygY6OqQqqd24ZiW8gpiRBBjrvFjC80/9rWY7O35UT8k+OppQZ3CJyCkr8U+I lOuWldQy9QZrmPewVnpx1yqC71Lcp+bIFYAKNzjL6zjbVN1FrrZDBVDJa0CsfNl2s2 TVR0GDyYqdNPWVDPaOsnRdi9wspYXMFaeeq3vOyW0vGXLqbrbOQTTkDne78n0e7wST 8f1CP74FdBztQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/11] mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new function Date: Mon, 24 Oct 2022 20:49:17 +0000 Message-Id: <20221024204919.18524-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610181259767166?= X-GMAIL-MSGID: =?utf-8?q?1747610181259767166?= 'damon_sysfs_schemes_update_stats()' is coupled with both damon_sysfs_kdamond and damon_sysfs_schemes. It's a wide range of types dependency. It makes splitting the logics a little bit distracting. Split the function so that each function is coupled with smaller range of types. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 129743292e17..082c55e68e0e 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2204,6 +2204,25 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx) mutex_unlock(&ctx->kdamond_lock); } +static void damon_sysfs_schemes_update_stats( + struct damon_sysfs_schemes *sysfs_schemes, + struct damon_ctx *ctx) +{ + struct damos *scheme; + int schemes_idx = 0; + + damon_for_each_scheme(scheme, ctx) { + struct damon_sysfs_stats *sysfs_stats; + + sysfs_stats = sysfs_schemes->schemes_arr[schemes_idx++]->stats; + sysfs_stats->nr_tried = scheme->stat.nr_tried; + sysfs_stats->sz_tried = scheme->stat.sz_tried; + sysfs_stats->nr_applied = scheme->stat.nr_applied; + sysfs_stats->sz_applied = scheme->stat.sz_applied; + sysfs_stats->qt_exceeds = scheme->stat.qt_exceeds; + } +} + /* * damon_sysfs_upd_schemes_stats() - Update schemes stats sysfs files. * @kdamond: The kobject wrapper that associated to the kdamond thread. @@ -2216,23 +2235,11 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx) static int damon_sysfs_upd_schemes_stats(struct damon_sysfs_kdamond *kdamond) { struct damon_ctx *ctx = kdamond->damon_ctx; - struct damon_sysfs_schemes *sysfs_schemes; - struct damos *scheme; - int schemes_idx = 0; if (!ctx) return -EINVAL; - sysfs_schemes = kdamond->contexts->contexts_arr[0]->schemes; - damon_for_each_scheme(scheme, ctx) { - struct damon_sysfs_stats *sysfs_stats; - - sysfs_stats = sysfs_schemes->schemes_arr[schemes_idx++]->stats; - sysfs_stats->nr_tried = scheme->stat.nr_tried; - sysfs_stats->sz_tried = scheme->stat.sz_tried; - sysfs_stats->nr_applied = scheme->stat.nr_applied; - sysfs_stats->sz_applied = scheme->stat.sz_applied; - sysfs_stats->qt_exceeds = scheme->stat.qt_exceeds; - } + damon_sysfs_schemes_update_stats( + kdamond->contexts->contexts_arr[0]->schemes, ctx); return 0; } From patchwork Mon Oct 24 20:49:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp684031wru; Mon, 24 Oct 2022 15:36:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40eDOhlhW/JnWEr+2V0zHkNOOcduBV3Sd6H79cNbBhUiTcWlLcJwixc5ZDkp6Kc3ls3SsW X-Received: by 2002:a17:907:6d8f:b0:78d:9b5e:1a0f with SMTP id sb15-20020a1709076d8f00b0078d9b5e1a0fmr30837107ejc.23.1666650975041; Mon, 24 Oct 2022 15:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650975; cv=none; d=google.com; s=arc-20160816; b=zgd4Re93yfqzUgzzTjItfm1ZlEkrf+QSOFLjpA5u2ix6bTUz2HpKz58m+x7hVy72oZ GJ3hQHEH7c8C56jjJF5CNuzjs/8KhY9kqJ4sHF+kV4oT2LuB3Qm07Nw1+ysfk7v+py9F SPIMXRSRfKxSfr9vPUx+yDv/C+d3rBVJvHnN54oWPT5oP8AhbjvyUjn5KeuMBEYFBILW Kp+q9Z6OLpovY3u5Frus226jr3UY+TDJTUI6iBmttDkVB0zKC4cyWN3PrGdpMs8nS+nK yXiPJiB8Bfsod04DN/5BzgtFbSXayy2EAh9E++6wYUARZqYpHmExuBAAiew7FMaRKLXv b+zw== 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=/psvwpgDunV61QtHA4+Z8aouaYxXpczLFew3kX5MTN0=; b=FZpTjVP0mUtTb87rHdgQA4lPKdYorzyGItbT19hFTAh1DWk2drDyYXoytGbwckvbIw ha6OC8g55TW1gJL5pLGqO1KxvqCyElJENoWpSIKSM49ssVDce0EA2JDX6bR8Oz5o4sei vkrfbx965K92uueArSNXcLa1OrK8uUfGocZ1RwzObtiqksSj4K8rQKojYxltYmaOgm4S 3qUU0lE+Q9hq6ufAc6CNvLjfxbXViovhLT+Wm2SpwlqAmCZXby327ebYmxKdtaZp0lHx hk6FehE6nnPa2JcS5f8Gxlr0x9jPu9vn3y/KBxC1+OJcLBDvFN3SFZUQDZg2ezmFjsVz xMoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gHf61vuV; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a170906580d00b0079d5da30399si791822ejq.427.2022.10.24.15.35.50; Mon, 24 Oct 2022 15:36:15 -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=gHf61vuV; 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 S230156AbiJXWdu (ORCPT + 99 others); Mon, 24 Oct 2022 18:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbiJXWdX (ORCPT ); Mon, 24 Oct 2022 18:33:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F2D12B9BBC for ; Mon, 24 Oct 2022 13:56:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id 26034B8125E for ; Mon, 24 Oct 2022 20:49:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AE46C433D6; Mon, 24 Oct 2022 20:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644570; bh=EqlatpkaNdYuUEktVCI5+LntE+Uir1CgxHGN/I9sz6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gHf61vuVWHDO8jflm6XY+Xnsxloq4pNPWgLulXZi12E0FTxFwZ5mbV4f2/jbeowuj vMMni2x0nAF+ylHWMo951Se91nJtcwHhrMT3YpMI7XdcXaIlL11P8MUbyRaSTF1eNU 9AnOGD3NlNADWrh7eR54eB+1HcDJQqIVbFK/de/aiy2Y1hGFQ4kbQu/rbalsRQniwi zSYR0fidKYCo1ckoWcY3nqjqcswTLW71/GQj0bchQeVPQ4qsXA6+O5Njhv1aGc+peD O9/H5LUfUIpb3DGPKZsfBhDz36iSpEJ8SA8a+puS2/V5c67HD8pKyyTLVmpLNev0kr 9NKxolELy7w6A== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH 10/11] mm/damon/modules: deduplicate init steps for DAMON context setup Date: Mon, 24 Oct 2022 20:49:18 +0000 Message-Id: <20221024204919.18524-11-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610212691020999?= X-GMAIL-MSGID: =?utf-8?q?1747610212691020999?= DAMON_RECLAIM and DAMON_LRU_SORT has duplicated code for DAMON context and target initializations. Deduplicate the part by implementing a function for the initialization in 'modules-common.c' and using it. Signed-off-by: SeongJae Park --- mm/damon/Makefile | 4 ++-- mm/damon/lru_sort.c | 17 +++------------- mm/damon/modules-common.c | 42 +++++++++++++++++++++++++++++++++++++++ mm/damon/modules-common.h | 3 +++ mm/damon/reclaim.c | 17 +++------------- 5 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 mm/damon/modules-common.c diff --git a/mm/damon/Makefile b/mm/damon/Makefile index f8d535a6253b..50d6b2ab3956 100644 --- a/mm/damon/Makefile +++ b/mm/damon/Makefile @@ -5,5 +5,5 @@ obj-$(CONFIG_DAMON_VADDR) += ops-common.o vaddr.o obj-$(CONFIG_DAMON_PADDR) += ops-common.o paddr.o obj-$(CONFIG_DAMON_SYSFS) += sysfs-common.o sysfs.o obj-$(CONFIG_DAMON_DBGFS) += dbgfs.o -obj-$(CONFIG_DAMON_RECLAIM) += reclaim.o -obj-$(CONFIG_DAMON_LRU_SORT) += lru_sort.o +obj-$(CONFIG_DAMON_RECLAIM) += modules-common.o reclaim.o +obj-$(CONFIG_DAMON_LRU_SORT) += modules-common.o lru_sort.o diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index efbc2bda8b9c..a1896c5acfe9 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -314,25 +314,14 @@ static int damon_lru_sort_after_wmarks_check(struct damon_ctx *c) static int __init damon_lru_sort_init(void) { - ctx = damon_new_ctx(); - if (!ctx) - return -ENOMEM; + int err = damon_modules_new_paddr_ctx_target(&ctx, &target); - if (damon_select_ops(ctx, DAMON_OPS_PADDR)) { - damon_destroy_ctx(ctx); - return -EINVAL; - } + if (err) + return err; ctx->callback.after_wmarks_check = damon_lru_sort_after_wmarks_check; ctx->callback.after_aggregation = damon_lru_sort_after_aggregation; - target = damon_new_target(); - if (!target) { - damon_destroy_ctx(ctx); - return -ENOMEM; - } - damon_add_target(ctx, target); - schedule_delayed_work(&damon_lru_sort_timer, 0); damon_lru_sort_initialized = true; diff --git a/mm/damon/modules-common.c b/mm/damon/modules-common.c new file mode 100644 index 000000000000..b2381a8466ec --- /dev/null +++ b/mm/damon/modules-common.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Common Primitives for DAMON Modules + * + * Author: SeongJae Park + */ + +#include + +#include "modules-common.h" + +/* + * Allocate, set, and return a DAMON context for the physical address space. + * @ctxp: Pointer to save the point to the newly created context + * @targetp: Pointer to save the point to the newly created target + */ +int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp, + struct damon_target **targetp) +{ + struct damon_ctx *ctx; + struct damon_target *target; + + ctx = damon_new_ctx(); + if (!ctx) + return -ENOMEM; + + if (damon_select_ops(ctx, DAMON_OPS_PADDR)) { + damon_destroy_ctx(ctx); + return -EINVAL; + } + + target = damon_new_target(); + if (!target) { + damon_destroy_ctx(ctx); + return -ENOMEM; + } + damon_add_target(ctx, target); + + *ctxp = ctx; + *targetp = target; + return 0; +} diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 5a4921851d32..f49cdb417005 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -44,3 +44,6 @@ 0400); \ module_param_named(nr_##qt_exceed_name, stat.qt_exceeds, ulong, \ 0400); + +int damon_modules_new_paddr_ctx_target(struct damon_ctx **ctxp, + struct damon_target **targetp); diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 162c9b1ca00f..3173f373435c 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -256,25 +256,14 @@ static int damon_reclaim_after_wmarks_check(struct damon_ctx *c) static int __init damon_reclaim_init(void) { - ctx = damon_new_ctx(); - if (!ctx) - return -ENOMEM; + int err = damon_modules_new_paddr_ctx_target(&ctx, &target); - if (damon_select_ops(ctx, DAMON_OPS_PADDR)) { - damon_destroy_ctx(ctx); - return -EINVAL; - } + if (err) + return err; ctx->callback.after_wmarks_check = damon_reclaim_after_wmarks_check; ctx->callback.after_aggregation = damon_reclaim_after_aggregation; - target = damon_new_target(); - if (!target) { - damon_destroy_ctx(ctx); - return -ENOMEM; - } - damon_add_target(ctx, target); - schedule_delayed_work(&damon_reclaim_timer, 0); damon_reclaim_initialized = true; From patchwork Mon Oct 24 20:49:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 10361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp683973wru; Mon, 24 Oct 2022 15:36:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57mQMRFhNA7uvOMJ6e0G0o0tPXQ7gQIl5t6YQZjWaQtkx6UeqBE9L8XDvIugqX01wbFgmq X-Received: by 2002:a05:6402:278d:b0:461:60d4:8ea4 with SMTP id b13-20020a056402278d00b0046160d48ea4mr15947445ede.419.1666650975684; Mon, 24 Oct 2022 15:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666650975; cv=none; d=google.com; s=arc-20160816; b=Lk//Tvf7hsCeYql+LDHU6w5wNwEHWO9l70OGl3hvy9kfxAYOdkY6RvP4sfb4lXM9Gm PSWrRXU+DC32cjnbvAjFPph668+0jhXJaxGXJDIzBB9TIAzMwomUHXQ+xUbI6STpDs/+ xiysYT8AKRpb7IrP2jTcbUlkNTuUICRx7Zj/Xk8WwvlWhGclO4Z+Ps1lvg46YgVs4mVO wnRVkv0vB3sJ8p6PQ+67JHjG2If8jnUEC3NFcxjAteA1LMHbn3VhtJR5XQ+YaBlDK3Dp 3dk7LBaCgjycJbcOIVmk2oTC/GeHq7DtPgj+7RHb21JmMr146nts2e/qz7FKmR5Q5FTL HgYA== 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=R4BxHqEmcuKW0c4tNNSt222xcKpiclvp60MW5YFbmHk=; b=xpnDBf+GnCnwVLqHc7J1I/VQTIDUAA9hE0/U8erVar4AVkOXsjcupT603sh+PBCK4v iYW/+hyFCT0Edtrrz6Jo8oMC9eMVvYIF+3pAjbrTcT8+YqFvKp9jNFsetxTFiHK1rVCE CiAHmhXLVX/B0+pTZJKG/c8BrMRu8AJaZz0/ekj0nTd4OTyU5GcrAtkpuqWk93i9vyR9 S9OucwK+zL88iiSgZFGeqN4Xz5IQ72rGulYFU95IvCPXMn8YqcRw9QfjnKX2B//guWM1 rp2kIsr3MioSGpuVjZN1Uh19MxwW855j7ovtYL3yketBgywFXcbHb61ZbtQCb9NkM05f yNhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J9cIXzhU; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170906708900b0078d8614e809si791247ejk.504.2022.10.24.15.35.51; Mon, 24 Oct 2022 15:36:15 -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=J9cIXzhU; 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 S231481AbiJXWaM (ORCPT + 99 others); Mon, 24 Oct 2022 18:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbiJXW3V (ORCPT ); Mon, 24 Oct 2022 18:29:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27FB91DDC0E for ; Mon, 24 Oct 2022 13:51:57 -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 96B76615C5 for ; Mon, 24 Oct 2022 20:49:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14B0FC433D7; Mon, 24 Oct 2022 20:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666644571; bh=ed3OO6jR2hviy6STfWb58XYnzMUxxyGe+e0xErjg1fk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J9cIXzhU9U1zWxdfPsC7S7cI+Ulc4SATnZVntGHQSe96wwChjQu3bcUIxth195MMp f4ukgLvBrlxZd/H8PRujs8KanGthShxmvvpLnHDKW1Lq299OzeaVMvog4X/ZgZdPDc gpM3BJ3Hn9RDw+azkUEHJHF155dHbvb5CGHOXw6Wpj2N2B1XvJx/RMFy6ILnUIFUIW PoUMZQoA9/tvPN6u7OKJusB50RP+v/mQIrqZw2hTUaX68Z3CYtid7Ykt9yjoi1Gflh D8BsHRcEsbV8Q8JtuFi3LFky/66KYi+CsQEkI+AyyL6UbExCY19nR679Fw2zEgoFJn 9ENAJnc8bWkRg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/11] mm/damon/{reclaim,lru_sort}: remove unnecessarily included headers Date: Mon, 24 Oct 2022 20:49:19 +0000 Message-Id: <20221024204919.18524-12-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221024204919.18524-1-sj@kernel.org> References: <20221024204919.18524-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747610213146859621?= X-GMAIL-MSGID: =?utf-8?q?1747610213146859621?= Some headers that 'recalim.c' and 'lru_sort.c' are including are unnecessary now owing to previous cleanups and refactorings. Remove those. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 2 -- mm/damon/reclaim.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index a1896c5acfe9..5c60163e556c 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -8,9 +8,7 @@ #define pr_fmt(fmt) "damon-lru-sort: " fmt #include -#include #include -#include #include #include "modules-common.h" diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 3173f373435c..e14eb30c01f4 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -8,9 +8,7 @@ #define pr_fmt(fmt) "damon-reclaim: " fmt #include -#include #include -#include #include #include "modules-common.h"