From patchwork Mon Jul 16 11:19:19 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: 10526487 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 84C55600D0 for ; Mon, 16 Jul 2018 11:19:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7580228A52 for ; Mon, 16 Jul 2018 11:19:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68C7C28A56; Mon, 16 Jul 2018 11:19:39 +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 F318828A52 for ; Mon, 16 Jul 2018 11:19:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E2496B0269; Mon, 16 Jul 2018 07:19:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 51F406B026A; Mon, 16 Jul 2018 07:19:35 -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 3697D6B026B; Mon, 16 Jul 2018 07:19:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id D1C456B0269 for ; Mon, 16 Jul 2018 07:19:34 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id k15-v6so8540384wrq.1 for ; Mon, 16 Jul 2018 04:19:34 -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:mime-version :content-transfer-encoding; bh=1jm8N0tmDjtgkM+dIlx18FolxwZwClFU7pHYv/N8f4Y=; b=FarCtyQNKqXWOpQE0/QI/ePa0oPmpiq0J9BfxmIIhXlYDhGP/LlRHqAAPNpk5JjEp9 OxNUn3NsRUPr9rckqGH78XztyM+4wWJyjktAW7Eq0wM9mv2uqMdnHfbqL+2dIyMCkvIG i597oSmXBdqW2M1PJXck0rq6QKh8l7DU20WYJN++/r/58aANSM6mnKwOg34SKjNlzvaK gn83ag3OwLTWucZ78uAGBjrJzW9EJzpRsgoXuzugn9+OkGM0Nt3dYi9gZAcOmc3ey64W 6VhJp2aIH7DIi0gTY4EYR2P6l4hrAxTMiQTG9J21ReUcR5STQeD1QPH6krh855c2//1x 0Luw== 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: AOUpUlESLr9BfddkjoJ241Oixs0YwEHKZeVuyL5Ck3ft5z0cvJLLvzXC A1fWC4J638bkqm7R6uQC6WvgC5Hlq8VVJLR2PhxpsGxQ/QTZrFGfAeRLpQpMQS+NItJtsppwxts dy9XZ8aR84Ia7re8PiLYolEmg8jynpMC1z54TdS/dW4hoK/3BkOK/nuHc7T13AnEwQA== X-Received: by 2002:adf:f148:: with SMTP id y8-v6mr11301851wro.134.1531739974377; Mon, 16 Jul 2018 04:19:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfkeKuhz34Vp46GCh0Nxfwgqh0+VN6ZZBGLOe1eR/Pzop8pR+6/qAkDT75rcXl3bYHwDeqO X-Received: by 2002:adf:f148:: with SMTP id y8-v6mr11301828wro.134.1531739973594; Mon, 16 Jul 2018 04:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531739973; cv=none; d=google.com; s=arc-20160816; b=NfZBQyFOJt1rUwP8Lf6ZdnqI1bYVSrOtz/P0U9LVTQp/T+Ge2aD8dCEMibGBt9HqRW OAG+g4egkNWLBsdOFU+BsCxERFI0uK7Kr0ShG2jZCfIYdTwshvtoVu3mnOwwrUAp/30h wvU06hpfLz47xPWMgxfxtCADwV94KdvwBBItuxT9tKXt8k3+GUBavSa6YVRRwVeZyq71 Ogo0Mc4PBzZAyCi/TnQG212aLrJ3722k6P3lnJXo0hiQ5Hbb2RUK6EYNPNE9q9N7jIQg dHaEIiqHJy5+O8/g1P1jDvQcmmUGsK2bU0G0epnlG2T3Nh0/Xg9MlEmc6UXEh3Rz+8mw ZWQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=1jm8N0tmDjtgkM+dIlx18FolxwZwClFU7pHYv/N8f4Y=; b=G0NPxVGrfJMe1WmlisDarJ8K+y7IX75emM6AMEHm8AFpA2oD4/I3zHoXXxOajUsRjL A0nsSb1/YWZSfQ2shqBVMFt3GFfdBztdc8WIryr6gwUIJJJg7ni4nKWYn+YVnyGpY6Yk K8CY3C0IJ8FQAnpE2PYDjx+Lf2vIo3yaMXOaHQS0bx+b5KII3ukUiurmG0f2kwcso6Ya f7i8l9QCvcF6eFB+wdlGmxw92uONNN+ypAkqNeBr269RCmd5Vv+KFrDSYy47LxmhOQQo Dl496CqqwF+IS8qMoyGNuhuNxTXjD9JrzGJ2+HRIbC3SgR8za0a1ciqb3+9RiAw9j9dp F0UA== 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 z8-v6si24940465wrv.127.2018.07.16.04.19.33 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 16 Jul 2018 04:19:33 -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 1ff1XO-0003CQ-Nh; Mon, 16 Jul 2018 13:19:30 +0200 From: Sebastian Andrzej Siewior To: linux-mm@kvack.org Cc: tglx@linutronix.de, Vladimir Davydov , Andrew Morton , Sebastian Andrzej Siewior Subject: [PATCH 2/4] mm/list_lru: Move locking from __list_lru_walk_one() to its caller Date: Mon, 16 Jul 2018 13:19:19 +0200 Message-Id: <20180716111921.5365-3-bigeasy@linutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716111921.5365-1-bigeasy@linutronix.de> References: <20180716111921.5365-1-bigeasy@linutronix.de> 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. Reviewed-by: Vladimir Davydov 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 344306714636..3e36e7a239e5 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -226,7 +226,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) { @@ -272,8 +271,6 @@ __list_lru_walk_one(struct list_lru *lru, int nid, int memcg_idx, BUG(); } } - - spin_unlock(&nlru->lock); return isolated; } @@ -282,8 +279,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); @@ -298,8 +301,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; }