Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6073890pxv; Thu, 29 Jul 2021 05:59:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDMN3sGr3oNQEjdypVEw5mmCbAKm985j5Rp0VtyPVSQMTgmPr2KYmgi2vIwJL5nHmj4XU0 X-Received: by 2002:a17:906:31cf:: with SMTP id f15mr4573389ejf.272.1627563587295; Thu, 29 Jul 2021 05:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627563587; cv=none; d=google.com; s=arc-20160816; b=nzhGQxEyAHeKpyhU8h05h0rVgwNE68huEzEJomM5UnjZzCn1IqqUHehYZb2Yvy05TB 0iKfTNVDTPgScRm8eIemb1aaiahemYQDgnWQMr6oMXs0cLh/+ih3JY1YSYkr2xza9cjE F5MJizav6M012RXfNN3jdi9++VyyrTJus+K01Gqw5d3mkeD8Qw3sZ7zHj/SdIhWZ/AYk kUvf9x7dxi7xeB9hAiyouuv4QCxrK4DA69KiiWgts7mvCx1cqJhlZCFZv04OPDNxuZDu UpdwHugcfXeppoCivBT6o8BARXHYAXwAdQN3OpBnaFH3460GmFGIQSOOp6LQrrUlApzw ljzA== 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; bh=565Hmjo9vPwZ9uGjd8O9XlyIQ2WwNN7GGL1e2uZpymo=; b=Wdv8ZtIJmHQF+RlYO2uojBXH62Lhbo6bNVVn4kxaYLwuRR/rbj/cCHQWXyhpxlmelT f+faqzbK8kAfsztfIUlSp8Y0QoIc96d2ItyR0bvI/B9u0z5raaV0GqFWVJ786f/rY2oy 6eXBS8yoyh20zhVP9J+8y/FwbRrcnbAtIVFEWiSnzrSzjrpzZqAsG5n5W/fHrQnC21+y HTOPsC6NrGBE6QES9np0+3ztsyvwRiDS6Y/5VxggYuoLH6FmSVNdQzpphA9Gz6isEA3D R2v8hjEe8W3OcIXEo+yvqM2me0XEsZehg9smEl3kpiMtSd55QE8dmdQRc8VwGfQHyW5V B+QA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qb29si749686ejc.254.2021.07.29.05.59.24; Thu, 29 Jul 2021 05:59:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237297AbhG2M6C (ORCPT + 99 others); Thu, 29 Jul 2021 08:58:02 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:13211 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237268AbhG2M6A (ORCPT ); Thu, 29 Jul 2021 08:58:00 -0400 Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Gb9Qk1XBcz1CQFL; Thu, 29 Jul 2021 20:51:58 +0800 (CST) Received: from huawei.com (10.175.124.27) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 29 Jul 2021 20:57:54 +0800 From: Miaohe Lin To: , , , CC: , , , , , , , , , Subject: [PATCH 2/5] mm, memcg: narrow the scope of percpu_charge_mutex Date: Thu, 29 Jul 2021 20:57:52 +0800 Message-ID: <20210729125755.16871-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210729125755.16871-1-linmiaohe@huawei.com> References: <20210729125755.16871-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since percpu_charge_mutex is only used inside drain_all_stock(), we can narrow the scope of percpu_charge_mutex by moving it here. Signed-off-by: Miaohe Lin --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6580c2381a3e..a03e24e57cd9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2050,7 +2050,6 @@ struct memcg_stock_pcp { #define FLUSHING_CACHED_CHARGE 0 }; static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock); -static DEFINE_MUTEX(percpu_charge_mutex); #ifdef CONFIG_MEMCG_KMEM static void drain_obj_stock(struct obj_stock *stock); @@ -2209,6 +2208,7 @@ static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages) */ static void drain_all_stock(struct mem_cgroup *root_memcg) { + static DEFINE_MUTEX(percpu_charge_mutex); int cpu, curcpu; /* If someone's already draining, avoid adding running more workers. */ -- 2.23.0