Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp344935ybm; Wed, 22 May 2019 04:17:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqybNGS+G9K7Nh+8dH2G+cUdjf42HEpSvcH+r/2KuYoKcu8yfjuWGZhgZ9RcTlFrzNlu6JgZ X-Received: by 2002:aa7:9563:: with SMTP id x3mr12615678pfq.118.1558523830115; Wed, 22 May 2019 04:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558523830; cv=none; d=google.com; s=arc-20160816; b=wABEEcZ2brvvaj1Tpm7ubbZT6HqfyTL/ycXSfYVX9c+C1jCyGXQFAjX0Xgw/Ci9NUH vkHVjnpz0AEqEorHbkIJN97SGdQekXA0JuNJt3Co1MMPWKt9pKWP1u6drIVAlO7DZedM pZlnkwjSQzj0dXyaf81h8g3VnanBBHUrHyu9GM09KheQFL7hpMwaiJrt8SfCyLzePZOZ 3QzIcTv9wvhOAB5BT1ZOMNNfjEHoq7WJOIrykF9AyLY7tvMUHwaG18rNyiI3S1x8sloy kiQj5F2dZTEr2L0uFXURP9oJLdmHBgm4P9I5unVn6fG148Jm2f+OKqs05xWA4fxVdGig iIwA== 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 :message-id:date:subject:cc:to:from; bh=PzLpshDAF1996b3NfsymDFsyRm8OkLMh8XXr3CnESiA=; b=WifioycHM8Xv6IbSxx28q1xqQ/s8945ixWXwBKHC0vr8MKCiyv/Azi6ewZBx+X9H7j a93qO1+OiMm2VXpRxpMbuN3eiiydNChlIbWc0Zonbb6bedXvBex+se22hJjiyt4S2+a2 9y34eYZ2egpmyeqDXpUupuqWUBkYcBhZtOndEMr1be4knOS+2F6/5DDGuv+GPYGLbxy1 P1nHaa9J3NvrECj/UBxTENXXWwzjmHL85EdJHjbaKoCWjwFtKuhMPph6+PyRX6I69PCE lbUwTcngJXwcT6ql4OlBAMlvUdrEZAHaXAYiBpTSzXYOThOA1OhYrhVKEbCTW+Qu2xaX F8iw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si24994935pgc.137.2019.05.22.04.16.54; Wed, 22 May 2019 04:17:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729284AbfEVLPo (ORCPT + 99 others); Wed, 22 May 2019 07:15:44 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48256 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728690AbfEVLPo (ORCPT ); Wed, 22 May 2019 07:15:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B76DC341; Wed, 22 May 2019 04:15:43 -0700 (PDT) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A8AA43F575; Wed, 22 May 2019 04:15:42 -0700 (PDT) From: Andrew Murray To: peterz@infradead.org, Thomas Gleixner Cc: Rik van Riel , linux-kernel@vger.kernel.org Subject: [PATCH] smp,cpumask: Don't call functions on offline CPUs Date: Wed, 22 May 2019 12:15:37 +0100 Message-Id: <20190522111537.27815-1-andrew.murray@arm.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we are able to allocate a cpumask in on_each_cpu_cond_mask we call functions with on_each_cpu_mask - this masks out offline cpus via smp_call_function_many. However when we fail to allocate a cpumask in on_each_cpu_cond_mask we call functions with smp_call_function_single - this will return -ENXIO from generic_exec_single if a CPU is offline which will result in a WARN_ON_ONCE. Let's avoid the WARN by only calling smp_call_function_single when the CPU is online and thus making both paths consistent with each other. Signed-off-by: Andrew Murray --- kernel/smp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index f4cf1b0bb3b8..10970692f1c0 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -259,6 +259,7 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline) /* * smp_call_function_single - Run a function on a specific CPU + * @cpu: The CPU to run on. * @func: The function to run. This must be fast and non-blocking. * @info: An arbitrary pointer to pass to the function. * @wait: If true, wait until function has completed on other CPUs. @@ -657,6 +658,8 @@ EXPORT_SYMBOL(on_each_cpu_mask); * completed on other CPUs. * @gfp_flags: GFP flags to use when allocating the cpumask * used internally by the function. + * @mask: The set of cpus to run on (only runs on online + subset). * * The function might sleep if the GFP flags indicates a non * atomic allocation is allowed. @@ -690,12 +693,13 @@ void on_each_cpu_cond_mask(bool (*cond_func)(int cpu, void *info), * just have to IPI them one by one. */ preempt_disable(); - for_each_cpu(cpu, mask) - if (cond_func(cpu, info)) { + for_each_cpu(cpu, mask) { + if (cpu_online(cpu) && cond_func(cpu, info)) { ret = smp_call_function_single(cpu, func, info, wait); WARN_ON_ONCE(ret); } + } preempt_enable(); } } -- 2.21.0