From patchwork Fri Sep 14 14:59:24 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: 10600913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA19815A7 for ; Fri, 14 Sep 2018 14:59:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC1812B8CE for ; Fri, 14 Sep 2018 14:59:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A02C32B8D0; Fri, 14 Sep 2018 14:59: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 3CD1A2B8CE for ; Fri, 14 Sep 2018 14:59:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E7508E0001; Fri, 14 Sep 2018 10:59:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 81ACB8E0004; Fri, 14 Sep 2018 10:59: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 6E3D98E0001; Fri, 14 Sep 2018 10:59:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 0F0D68E0004 for ; Fri, 14 Sep 2018 10:59:35 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id u12-v6so10504502wrc.1 for ; Fri, 14 Sep 2018 07:59:35 -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=jycUThBL+jyg5DdP317vUo9nsuQyw7JLVDvltXGVpsE=; b=I6356fMHHfnqGQ16N9DM4UM0JNzKsADUQGmJSwV+xW+L03I4ugvxklU3dpXB+QUJxl eETurTULRlUe6w/M+8WErzsytk6l2NrxL3glAqQfGrY1tqTqEXVzHAN8Vh0MJ1jiqyPV zwh21nF8PFnDU3HdlyPxgxQygZVweC0or4sZgYYfZFZZVEizmat4LBLXUsWG6RQq041C 3QZ512hSs/u8w0hjJcHDIOmyg4dSi6kZFgLRhoAXWyXtfdorlgbUYrd5q30IfFyH6eWw tOFAAqlEtOTejXBkbjpVNpKnYjRGcq1v5JJ5TK8f9CrZliDTOAefCXI4V9u7S5F8ahx3 zYZw== 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: APzg51CY7+aY9sL2vulGF7C0a+Kfo5kfhkABd0Y+ZxhPME7bKZ2cBUdk FJuSxTS+tVGihelqDwDwB71Wnu8YqngtUEuQjv1qsce7XFJLtWnAbZQ+/VIQLRx3Au8ldWjpI4n Ez5SAmPrlrgDBUbGbHn4AP0OpzFLkmwTXOG5zfy1XyOJQTscwVkcUxllpUerLspIYIw== X-Received: by 2002:a1c:cf8a:: with SMTP id f132-v6mr2672178wmg.0.1536937174583; Fri, 14 Sep 2018 07:59:34 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbp0kEGA+vhnhNowB+0KEgFxFMfWTnxECY38YL7d+LUO7FvyWvIh6uJDiLDsoEC2sXX3u5H X-Received: by 2002:a1c:cf8a:: with SMTP id f132-v6mr2672132wmg.0.1536937173692; Fri, 14 Sep 2018 07:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536937173; cv=none; d=google.com; s=arc-20160816; b=HjBt4pMR/A/2QH/B+ahlXxEqsGGc7Fxs2kPYexTWgQagvKfYD/QEQD9pxUBEe1pjF9 BCU56UrN/6Qcydp1Q5XXB62IZxhiK8Fmt5+Qdv2a+2/emT48zSMvglLT1lZ5tKtHJ8eU szeMZ+vXiOVw83k30yRrLMS0srmJxlrOyC5bEaz2Q/GPJ61VuHpH/juWSJMwe+bWLHGs K46Ya2RIMhtkAUeE+wDociDmFnPbLvcSTdcdqQjDydyXzNRwthK5wrKAObTdPlWN035r juMFWTSr+UauDr15j0dE8cZz89OerwwAgP9E3C1DdsqaKwMLca3NdiFCAaTT+iLv2BeI Sikw== 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; bh=jycUThBL+jyg5DdP317vUo9nsuQyw7JLVDvltXGVpsE=; b=BuPdYxqYJksjkeq9GVQTnNlPBhxmaGgKR840INvs6uKT3mVXMF/jcX9tftOPu+pdRF 8Gn2lz9RVv/anKcBhgJELiizTK0XX5OxtIbB6OraaujzF5zgW6MTdlvrp3j2Qeb6zY78 0oAdSOIJtCNuUf5BToCb4CBgrflyexwGcc5ygmtyTEiSicipeUvk/wFqe5sscXi+Frpo oa9leIjA5FTRyn6FR06MnF/z6zYL/FefQ34IiirqcdPAepQuhwbBB+yHsK6qD2YBCvwi Rf1ueW1c0F8fnxi2rSQIb3Lh9pludoH+BHeXIK7BwtZLStSVl1PTWPqgmN4s73MbkQHo 8JjQ== 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 b192-v6si1894684wmd.110.2018.09.14.07.59.33 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 14 Sep 2018 07:59: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 1g0pZC-00019w-4L; Fri, 14 Sep 2018 16:59:30 +0200 From: Sebastian Andrzej Siewior To: linux-mm@kvack.org Cc: tglx@linutronix.de, Vlastimil Babka , frederic@kernel.org, Sebastian Andrzej Siewior Subject: [PATCH 2/2] mm/swap: Access struct pagevec remotely Date: Fri, 14 Sep 2018 16:59:24 +0200 Message-Id: <20180914145924.22055-3-bigeasy@linutronix.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180914145924.22055-1-bigeasy@linutronix.de> References: <20180914145924.22055-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 From: Thomas Gleixner Now that struct pagevec is locked during access, it is possible to access it from a remote CPU. The advantage is that the work can be done from the "requesting" CPU without firing a worker on a remote CPU and waiting for it to complete the work. Signed-off-by: Thomas Gleixner [bigeasy: +commit message] Signed-off-by: Sebastian Andrzej Siewior --- mm/swap.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 17702ee5bf81c..ec36e733aab5d 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -733,54 +733,19 @@ void lru_add_drain(void) lru_add_drain_cpu(raw_smp_processor_id()); } -static void lru_add_drain_per_cpu(struct work_struct *dummy) -{ - lru_add_drain(); -} - -static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work); - -/* - * Doesn't need any cpu hotplug locking because we do rely on per-cpu - * kworkers being shut down before our page_alloc_cpu_dead callback is - * executed on the offlined cpu. - * Calling this function with cpu hotplug locks held can actually lead - * to obscure indirect dependencies via WQ context. - */ void lru_add_drain_all(void) { - static DEFINE_MUTEX(lock); - static struct cpumask has_work; int cpu; - /* - * Make sure nobody triggers this path before mm_percpu_wq is fully - * initialized. - */ - if (WARN_ON(!mm_percpu_wq)) - return; - - mutex_lock(&lock); - cpumask_clear(&has_work); - for_each_online_cpu(cpu) { - struct work_struct *work = &per_cpu(lru_add_drain_work, cpu); - if (pagevec_count(&per_cpu(lru_add_pvec.pvec, cpu)) || pagevec_count(&per_cpu(lru_rotate_pvecs.pvec, cpu)) || pagevec_count(&per_cpu(lru_deactivate_file_pvecs.pvec, cpu)) || pagevec_count(&per_cpu(lru_lazyfree_pvecs.pvec, cpu)) || need_activate_page_drain(cpu)) { - INIT_WORK(work, lru_add_drain_per_cpu); - queue_work_on(cpu, mm_percpu_wq, work); - cpumask_set_cpu(cpu, &has_work); + lru_add_drain_cpu(cpu); } } - - for_each_cpu(cpu, &has_work) - flush_work(&per_cpu(lru_add_drain_work, cpu)); - - mutex_unlock(&lock); } /**