From patchwork Tue Jul 3 14:52:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10504233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C191602BC for ; Tue, 3 Jul 2018 14:52:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF8C928C5D for ; Tue, 3 Jul 2018 14:52:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E419C28C69; Tue, 3 Jul 2018 14:52:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8595F28C5D for ; Tue, 3 Jul 2018 14:52:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D8C86B000A; Tue, 3 Jul 2018 10:52:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 08B2F6B000C; Tue, 3 Jul 2018 10:52:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E974C6B000D; Tue, 3 Jul 2018 10:52:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f200.google.com (mail-wr0-f200.google.com [209.85.128.200]) by kanga.kvack.org (Postfix) with ESMTP id 8B8BE6B000A for ; Tue, 3 Jul 2018 10:52:53 -0400 (EDT) Received: by mail-wr0-f200.google.com with SMTP id s14-v6so1136295wra.0 for ; Tue, 03 Jul 2018 07:52:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=GFDrZmVPDPk9Omr0o8zUgx5tVW8mXINTjKkDKhkysGk=; b=ti4DhH8GX7Kxzzp4gF+aytAPpZF3ynENKxyZFB4JuH5iZ3f8KbvoVx4L1KxLq1m+KS 2hfEQZbXtuWSerwomcBDZhwIYe8gY/EtjhO+T8haLtfbFm90JAaqs05gvFGXjt9TQxEE cb71FzH0XfUPAFW49JaSkXcam6gYgFUIu7nisBhQRMYIsNXeWgdHBUtjiPkZFvrbj02d 9/U8y384W8TYN4Ew35fRWK2+OYqHZxtPYzMBjx4CpArCdtmaPc4ddvScjjvbHiFHrrSn pHY2vL5TYJiIsvRIDNLwtBNDATnFyVgY2AOnxintIUa9sFOhivWL1kPEFdcSOKB/TbDL w+CA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bigeasy@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de X-Gm-Message-State: APt69E2+D5utKzf2iO/UQJegNnac3LHNThqpGHYVRBOu7y/SMnCqC6V4 ZofDpoIvl/sSRokikMseYkBfAH/DbjXUy/a8lnyE6rZhBPwk9CTPXqogt6Xrk2rYlns2rk0t2/F MAIpliDAMIegIy8XI3koPw5U67MECF/knEboRX0bWYnPcfyeyBzWw0fF4I0iPSVmfgw== X-Received: by 2002:a1c:2bc7:: with SMTP id r190-v6mr11111456wmr.26.1530629573109; Tue, 03 Jul 2018 07:52:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfMQq1qCERjVQ5kYnYu5izOqrfRR6ehGbzRbm21bve3vCn+VpzpuDrBUIqlO8iPVgMzXGS6 X-Received: by 2002:a1c:2bc7:: with SMTP id r190-v6mr11111406wmr.26.1530629571869; Tue, 03 Jul 2018 07:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530629571; cv=none; d=google.com; s=arc-20160816; b=pRhlzRZVqmYnZlok8fO16iQYPh4hx9PMGhw0JDsX8aY01QrQgCrEH1W+z3xj66PZ4+ aKjhAY+cD4odfeV1hQX34MPXrSVepQQapGEQCYNoJeGKJMmfhw8MKt7MNInlRLa9EmtU aJ5Bdpj2oj+OeMDIp7laNVu4QnJojrWiLfaBTE47KxW4z4FqVAwJNryx87ZTEJgkt7Ig TS5MEre5/2ZPClA4Ti6VeLX8jF4SnDsQlLPftOGAGvj1hSGarTo/9C2RsbEUjUPPxcfP Xx/jC1Yfxz64mpj0Egrwn4YJaovjidbX3292PMjBpBAAlkvyUyikcp+DBsO+k7gAUPsM R8ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GFDrZmVPDPk9Omr0o8zUgx5tVW8mXINTjKkDKhkysGk=; b=HP6588Pc5Y8xcZvZPrknrYQBnnN8uOnWFqpj0xZk84hSWe8ogeu83WwZP+pHJvJRb4 f0mcyLgQzX7w+CZhbeh1YlffH87v2ZDWhX/PHLVpeiQV+MLW20D62HZuOu3o9J9keI2F UqY1gHHJ4uo6yWqItodXEq4k6N4QrmgTfDQEeg67Z5xOUIn5+uX+VxlMwkrQCGUvSyU3 xlVtXa3RsGz0GEzNUR0PvF5Es8VuHmNfMPa51t5LST0May2XL5h3EnEwaIIy4DZD0Eqg KZEMpEefGf5/uSdKglmofnHvp/F4zp57Q1c9gw9crE1T8XmRpITwleZ/Xayi+2LVBRhY RPsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of bigeasy@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id z13-v6si1218767wrg.240.2018.07.03.07.52.51 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 03 Jul 2018 07:52:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bigeasy@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) client-ip=2a01:7a0:2:106d:700::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bigeasy@linutronix.de designates 2a01:7a0:2:106d:700::1 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1faMfi-000384-HO; Tue, 03 Jul 2018 16:52:50 +0200 From: Sebastian Andrzej Siewior To: Vladimir Davydov Cc: linux-mm@kvack.org, tglx@linutronix.de, Andrew Morton , Sebastian Andrzej Siewior Subject: [PATCH 2/4] mm/list_lru: Move locking from __list_lru_walk_one() to its caller Date: Tue, 3 Jul 2018 16:52:33 +0200 Message-Id: <20180703145235.28050-3-bigeasy@linutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180703145235.28050-1-bigeasy@linutronix.de> References: <20180624200907.ufjxk6l2biz6xcm2@esperanza> <20180703145235.28050-1-bigeasy@linutronix.de> Reply-To: "[PATCH 0/4]"@kvack.org, "mm/list_lru:add"@kvack.org, list_lru_shrink_walk_irq@kvack.org, and@kvack.org (), use@kvack.org, it@kvack.org MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Move the locking inside __list_lru_walk_one() to its caller. This is a preparation step in order to introduce list_lru_walk_one_irq() which does spin_lock_irq() instead of spin_lock() for the locking. Signed-off-by: Sebastian Andrzej Siewior --- mm/list_lru.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mm/list_lru.c b/mm/list_lru.c index ddbffbdd3d72..819e0595303e 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -204,7 +204,6 @@ __list_lru_walk_one(struct list_lru *lru, int nid, int memcg_idx, struct list_head *item, *n; unsigned long isolated = 0; - spin_lock(&nlru->lock); l = list_lru_from_memcg_idx(nlru, memcg_idx); restart: list_for_each_safe(item, n, &l->list) { @@ -250,8 +249,6 @@ __list_lru_walk_one(struct list_lru *lru, int nid, int memcg_idx, BUG(); } } - - spin_unlock(&nlru->lock); return isolated; } @@ -260,8 +257,14 @@ list_lru_walk_one(struct list_lru *lru, int nid, struct mem_cgroup *memcg, list_lru_walk_cb isolate, void *cb_arg, unsigned long *nr_to_walk) { - return __list_lru_walk_one(lru, nid, memcg_cache_id(memcg), - isolate, cb_arg, nr_to_walk); + struct list_lru_node *nlru = &lru->node[nid]; + unsigned long ret; + + spin_lock(&nlru->lock); + ret = __list_lru_walk_one(lru, nid, memcg_cache_id(memcg), + isolate, cb_arg, nr_to_walk); + spin_unlock(&nlru->lock); + return ret; } EXPORT_SYMBOL_GPL(list_lru_walk_one); @@ -276,8 +279,13 @@ unsigned long list_lru_walk_node(struct list_lru *lru, int nid, nr_to_walk); if (*nr_to_walk > 0 && list_lru_memcg_aware(lru)) { for_each_memcg_cache_index(memcg_idx) { + struct list_lru_node *nlru = &lru->node[nid]; + + spin_lock(&nlru->lock); isolated += __list_lru_walk_one(lru, nid, memcg_idx, isolate, cb_arg, nr_to_walk); + spin_unlock(&nlru->lock); + if (*nr_to_walk <= 0) break; }