From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6858DC04A68 for ; Thu, 28 Jul 2022 18:04:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08CB1940007; Thu, 28 Jul 2022 14:04:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03B908E0001; Thu, 28 Jul 2022 14:04:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4624940007; Thu, 28 Jul 2022 14:04:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C6C308E0001 for ; Thu, 28 Jul 2022 14:04:17 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9CBDD415A4 for ; Thu, 28 Jul 2022 18:04:17 +0000 (UTC) X-FDA: 79737282954.27.543B400 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by imf06.hostedemail.com (Postfix) with ESMTP id 2BCCD1800AB for ; Thu, 28 Jul 2022 18:04:17 +0000 (UTC) Received: by mail-io1-f49.google.com with SMTP id r70so1945613iod.10 for ; Thu, 28 Jul 2022 11:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=/dJeOyrY32LeD/c96pF29k6qqscTBj4IUisD45XkhKs=; b=sfv2k4Xm/tn87w1RZLO8FOjzLhbfRZ0VkvQC5BbL/cU3dSAR0fGGSWuGDy7PS4Cf2f efiIq/KFORaO2gEA48T7SvGYCKCscEVhfGRFs5O4YJzqED4oPrEa3lEO9bs5pK6+gpdg r9PAOeTZ9Khc2/SXLRmw9PIEB1q0UZzhbK+g9j9mPKWD9YuYhezt5UvTlpKSEHvzBf+w IRxpsZvc/FQmtQcaQCGgqr0cSBCuvPBole5a7rDbCFO4/qdxRrQmiADCJ1lvC5MA3ykg dKve/rltNo6BZvZ6OgzUKyf9YHcI75r9uGfoA1vKeQst05fk23opemZQsmStdWHggfDK 3g/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=/dJeOyrY32LeD/c96pF29k6qqscTBj4IUisD45XkhKs=; b=GjMwHf/kZ059gEIjZ4/Xhk1vSxGjy5Mnq6q+5T6GI5+L5zd3+XkYohJjaWSfVbHaZI tye8I/X1kxqt/5i0linPszHgrvcSra8YGfuxsyIeI5EsYn/taEL3K3wgsSNa14Dlc7zg oTO6YIQDpNTFDsJsnPny+FQ5EVZm8Qpr9d6fMl82/JN+j3FYE72RPx8TQXp4oKIo9SxG sJ61rPdE6+BK+Sirogzy/rEaTuS3KAI7PbKSSgRII9fI1ZPMun3DaUz8kKRe620j/L/L jQFAoDjKDgm1mCBydmriCMleArzdklUPZLqUws1NBFsWbXlG/gpEUMnaMl+FpaU8MDr+ NssA== X-Gm-Message-State: AJIora85JYwpSfeUdt/DciJSSl3V8W6CmQtWLN9YCdF99yPUXG+hO/sn TiXZ+/DJqjRH4wY6C9isM9XvONphrsRQUz/z7t+tWQ== X-Google-Smtp-Source: AGRyM1vQouBSbAXh5O9Co4to1ZBdIZlO3QBZ2cX2OKYPjdi49u5yXuFGSy0ITyOAjSOdTKXHvq2mIvJKxK/+OdyCBn8= X-Received: by 2002:a02:854b:0:b0:341:7894:6c50 with SMTP id g69-20020a02854b000000b0034178946c50mr6545jai.234.1659031456487; Thu, 28 Jul 2022 11:04:16 -0700 (PDT) MIME-Version: 1.0 References: <20220728121949.20985-1-linmiaohe@huawei.com> <20220728121949.20985-7-linmiaohe@huawei.com> In-Reply-To: <20220728121949.20985-7-linmiaohe@huawei.com> From: Mina Almasry Date: Thu, 28 Jul 2022 11:04:05 -0700 Message-ID: Subject: Re: [PATCH 6/6] hugetlb_cgroup: use helper for_each_hstate and hstate_index To: Miaohe Lin Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sfv2k4Xm; spf=pass (imf06.hostedemail.com: domain of almasrymina@google.com designates 209.85.166.49 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659031457; a=rsa-sha256; cv=none; b=zUPntSimPzh71s/3yAvBIP9CRSyNNBLlNwlOPAo2pr85+vISI/TpdQIh+H/2HD2zJTlU/e uBXJmRT14i77aE6ayT1I6Y+/zQvqu1DYvLRgByLjhID0TQ7oB+Y11Gq4g+SGF+qzXEnqWl G4NaYqGnyYe61viXEFhbTyxcVPSi8v4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659031457; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/dJeOyrY32LeD/c96pF29k6qqscTBj4IUisD45XkhKs=; b=rnquD7pssqLPhKVtKjXJfKvdY8nF+reo4EBTBGeyJ/kPevJVCeg9TjH/MHhP3t2Cv7z7Wo 4vx48x4sBmCyBgCYv6d2Fp6tcvkR8CWm7JqSo2bdX5lnil++y/89GwcXTwg+/GsOyDunHb MZbhkbv0K50S2HW9/lSFC/JrITEGdl0= X-Stat-Signature: gy6gtc43pc9penq1esyboz45azpybe6y X-Rspamd-Queue-Id: 2BCCD1800AB X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sfv2k4Xm; spf=pass (imf06.hostedemail.com: domain of almasrymina@google.com designates 209.85.166.49 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam12 X-HE-Tag: 1659031457-163507 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jul 28, 2022 at 5:20 AM Miaohe Lin wrote: > > Use helper for_each_hstate and hstate_index to iterate the hstate and get > the hstate index. Minor readability improvement. > > Signed-off-by: Miaohe Lin Reviewed-by: Mina Almasry > --- > mm/hugetlb_cgroup.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c > index 13ec091385af..8f20082df4c8 100644 > --- a/mm/hugetlb_cgroup.c > +++ b/mm/hugetlb_cgroup.c > @@ -74,11 +74,11 @@ parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg) > > static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg) > { > - int idx; > + struct hstate *h; > > - for (idx = 0; idx < hugetlb_max_hstate; idx++) { > + for_each_hstate(h) { > if (page_counter_read( > - hugetlb_cgroup_counter_from_cgroup(h_cg, idx))) > + hugetlb_cgroup_counter_from_cgroup(h_cg, hstate_index(h)))) > return true; > } > return false; > @@ -224,17 +224,14 @@ static void hugetlb_cgroup_css_offline(struct cgroup_subsys_state *css) > struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(css); > struct hstate *h; > struct page *page; > - int idx; > > do { > - idx = 0; > for_each_hstate(h) { > spin_lock_irq(&hugetlb_lock); > list_for_each_entry(page, &h->hugepage_activelist, lru) > - hugetlb_cgroup_move_parent(idx, h_cg, page); > + hugetlb_cgroup_move_parent(hstate_index(h), h_cg, page); > > spin_unlock_irq(&hugetlb_lock); > - idx++; > } > cond_resched(); > } while (hugetlb_cgroup_have_usage(h_cg)); > -- > 2.23.0 >