From patchwork Wed Jun 22 17:06:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891174 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 CA79CC433EF for ; Wed, 22 Jun 2022 17:07:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AC288E00CF; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 454578E00D1; Wed, 22 Jun 2022 13:06:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB3136B00D6; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A67608E00C9 for ; Wed, 22 Jun 2022 13:06:52 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E5403204D3 for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) X-FDA: 79606501380.02.C08C610 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf23.hostedemail.com (Postfix) with ESMTP id 343091400B4 for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LSqVd6XLFzhYds; Thu, 23 Jun 2022 01:04:25 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 23 Jun 2022 01:06:33 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 13/16] mm/huge_memory: add helper __get_deferred_split_queue Date: Thu, 23 Jun 2022 01:06:24 +0800 Message-ID: <20220622170627.19786-14-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=mAFJeqBQ8lXYRD9z+B5ArsMpYnoyT0jDsj/jF90joY07Wojn8pw0c8izxTKaOTd17p9mLD HRbgWpnz2ytvygmuhkRRP4hDgHTHXeQFEt35dsJnJm4/iU7MCxomfRo1sEm4ZmOSQXVA17 LlIaHN0e+CQiE5PAtj0LG5+BK18OTMs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655917609; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WV+C+ZhSlalt/ScQz1oP6rV/W+OqiyyCTiyJ7nlsCng=; b=AJXbJwv6/zLZRa07jt/xcqH3xQVyTew2KiwqDdMufJ2w9iC2bhcan6xxdm4UgzwQXtVHLu I4sT9gpQr2701vS32Yp8Q54zQAMmaslqnpcP0mk9Nc26EeKGRmSj1Sd+x1gaTleloxL/EE EQZrB25P5MwDb8XXNYKGIBklbWaDch8= X-Stat-Signature: qepjqzkgctu6itg3f8tiqx4fi9af7whh X-Rspamd-Server: rspam06 Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Queue-Id: 343091400B4 X-HE-Tag: 1655917609-246281 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: Add helper __get_deferred_split_queue to remove the duplicated codes of getting ds_queue. No functional change intended. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0030b4f67cd9..de8155ff584c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -555,25 +555,23 @@ pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma) return pmd; } -#ifdef CONFIG_MEMCG -static inline struct deferred_split *get_deferred_split_queue(struct page *page) +static inline struct deferred_split *__get_deferred_split_queue(struct pglist_data *pgdat, + struct mem_cgroup *memcg) { - struct mem_cgroup *memcg = page_memcg(compound_head(page)); - struct pglist_data *pgdat = NODE_DATA(page_to_nid(page)); - +#ifdef CONFIG_MEMCG if (memcg) return &memcg->deferred_split_queue; - else - return &pgdat->deferred_split_queue; +#endif + return &pgdat->deferred_split_queue; } -#else + static inline struct deferred_split *get_deferred_split_queue(struct page *page) { + struct mem_cgroup *memcg = page_memcg(compound_head(page)); struct pglist_data *pgdat = NODE_DATA(page_to_nid(page)); - return &pgdat->deferred_split_queue; + return __get_deferred_split_queue(pgdat, memcg); } -#endif void prep_transhuge_page(struct page *page) { @@ -2774,31 +2772,22 @@ void deferred_split_huge_page(struct page *page) static unsigned long deferred_split_count(struct shrinker *shrink, struct shrink_control *sc) { - struct pglist_data *pgdata = NODE_DATA(sc->nid); - struct deferred_split *ds_queue = &pgdata->deferred_split_queue; + struct deferred_split *ds_queue; -#ifdef CONFIG_MEMCG - if (sc->memcg) - ds_queue = &sc->memcg->deferred_split_queue; -#endif + ds_queue = __get_deferred_split_queue(NODE_DATA(sc->nid), sc->memcg); return READ_ONCE(ds_queue->split_queue_len); } static unsigned long deferred_split_scan(struct shrinker *shrink, struct shrink_control *sc) { - struct pglist_data *pgdata = NODE_DATA(sc->nid); - struct deferred_split *ds_queue = &pgdata->deferred_split_queue; + struct deferred_split *ds_queue; unsigned long flags; LIST_HEAD(list), *pos, *next; struct page *page; int split = 0; -#ifdef CONFIG_MEMCG - if (sc->memcg) - ds_queue = &sc->memcg->deferred_split_queue; -#endif - + ds_queue = __get_deferred_split_queue(NODE_DATA(sc->nid), sc->memcg); spin_lock_irqsave(&ds_queue->split_queue_lock, flags); /* Take pin on all head pages to avoid freeing them under us */ list_for_each_safe(pos, next, &ds_queue->split_queue) {