Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3231535imc; Wed, 13 Mar 2019 12:13:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZEj3I5idjn89IJZB3G+ns5cGT7Np9NywaffUoe8c0TxfJenUzzP3dGbK9tWXk7JM+zbkl X-Received: by 2002:a63:6a88:: with SMTP id f130mr41156059pgc.114.1552504439457; Wed, 13 Mar 2019 12:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552504439; cv=none; d=google.com; s=arc-20160816; b=tNu1dVMjq1/DgKoDLvMGELvl9fzAsw6C7FadNPwOlLLXbQi+EjA3k/GuO3uUs6S0bK Kqszo65ipvq0mY/fj0XwgBcVezZ6BzFMR/agZnlbwaIBhnWOQQ0CgEUGThHN+6W/7cwk pB03KW0DESG43OvWOXEiNiM4+ooIaveQGFQgUrYeYk+lBIyNZf6lthh9BuJvMx40sNfH QxhhES2YsAXQMaj/QNAFSTT2A3DUKS09S2Mwkp88ANkHtKgo4oEtkc/UybermU1JFvDa 1b5SjYP9C4R3Oe1L5kjaD6LpSq7fCF4pZqHkKJk4HVtkDIqD/eJbmMk2fedfXXU/7Ih9 DdDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Tag9EqO03KMHYu8p++5IfmVZggsrAI5p9kAMMcr9Ug=; b=SSpPCV5iniZedX9Nu040IsdpD5UW4nUioKBkFzPshkQ3VAtKlaLorlKDAJvZ4SWs6i oxir54Y4CUU0vNt32QeRJpxnTxWxifLQTcsY42wSYfZ+1SNF/J88h+MiYS9sS+ekVUaf HZmCv8NtnLlO+IDkB+Rz7mnFkGhPZHU1IY5gu30PdHGZMrqgs8IHYskBPh7/osjoBKA1 TT6xoXd7Lh5dtSpVoGSDkurLJux5ZRVtNExXk3RkOLZd2Erm98vU479hr2sGQaYQfuuI vstoeAXAoK8KlLjLhJH4HLmd99UdhvaZFTnZvGmAnkgrTtB93mkBGVZ9Loljo8Wt5KY8 WQEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mZKNr6LS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si10387443pgs.98.2019.03.13.12.13.43; Wed, 13 Mar 2019 12:13:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mZKNr6LS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727544AbfCMTLl (ORCPT + 99 others); Wed, 13 Mar 2019 15:11:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbfCMTLk (ORCPT ); Wed, 13 Mar 2019 15:11:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 72385213A2; Wed, 13 Mar 2019 19:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552504299; bh=jxkikg5QHx//0IM4ZsTVNLsYhaj12DfblrWwOmRjxp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mZKNr6LSCcahl+kNRMGJFPNgnCEjY6H6QB5zTBRhSt0Opp8KoYEjdD/SkRHdOi3Yt 5f3J52iaY3jy+7XqJfZwIWGnBJOx2TvMx55sBWeBfdRtXfcaFLFhCDl/nNScB3x4dU 0FKlKmCwvlo/inOsAqLjefaENTjFdWwayEuXF3Ao= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michal Hocko , Tejun Heo , Andrew Morton , Linus Torvalds , Sasha Levin , linux-mm@kvack.org Subject: [PATCH AUTOSEL 4.20 35/60] mm: handle lru_add_drain_all for UP properly Date: Wed, 13 Mar 2019 15:09:56 -0400 Message-Id: <20190313191021.158171-35-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190313191021.158171-1-sashal@kernel.org> References: <20190313191021.158171-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko [ Upstream commit 6ea183d60c469560e7b08a83c9804299e84ec9eb ] Since for_each_cpu(cpu, mask) added by commit 2d3854a37e8b767a ("cpumask: introduce new API, without changing anything") did not evaluate the mask argument if NR_CPUS == 1 due to CONFIG_SMP=n, lru_add_drain_all() is hitting WARN_ON() at __flush_work() added by commit 4d43d395fed12463 ("workqueue: Try to catch flush_work() without INIT_WORK().") by unconditionally calling flush_work() [1]. Workaround this issue by using CONFIG_SMP=n specific lru_add_drain_all implementation. There is no real need to defer the implementation to the workqueue as the draining is going to happen on the local cpu. So alias lru_add_drain_all to lru_add_drain which does all the necessary work. [akpm@linux-foundation.org: fix various build warnings] [1] https://lkml.kernel.org/r/18a30387-6aa5-6123-e67c-57579ecc3f38@roeck-us.net Link: http://lkml.kernel.org/r/20190213124334.GH4525@dhcp22.suse.cz Signed-off-by: Michal Hocko Reported-by: Guenter Roeck Debugged-by: Tetsuo Handa Cc: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/swap.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index aa483719922e..e99ef3dcdfd5 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -320,11 +320,6 @@ static inline void activate_page_drain(int cpu) { } -static bool need_activate_page_drain(int cpu) -{ - return false; -} - void activate_page(struct page *page) { struct zone *zone = page_zone(page); @@ -653,13 +648,15 @@ void lru_add_drain(void) put_cpu(); } +#ifdef CONFIG_SMP + +static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work); + 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 @@ -702,6 +699,12 @@ void lru_add_drain_all(void) mutex_unlock(&lock); } +#else +void lru_add_drain_all(void) +{ + lru_add_drain(); +} +#endif /** * release_pages - batched put_page() -- 2.19.1