Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp110897imu; Mon, 10 Dec 2018 17:17:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/U9q8l+nwsUnCC4AFDdQjUbe9ZTwaaOEokPQ6mg4onEfwHCqsL7VGJQWH1IKPBTrZClXDKv X-Received: by 2002:a63:1904:: with SMTP id z4mr12459997pgl.135.1544491056087; Mon, 10 Dec 2018 17:17:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544491056; cv=none; d=google.com; s=arc-20160816; b=zDjDpzOuesUf2i7kYDwV5gW9k2DhYJzm3rpxh/ncGBaxkkmBjbmHV+VeVQQaLHpgUd 61fPeFOyViAM7OTLIKAywGks5MnWWYH4ps/ciAsLXWP3A2AQtau6Sd1ObAlGoaSE6CD2 IWIlsI3N5cKZ2DKQvjMU4bfiiQwJMT1QlwuqCr1PkDMb7RDr2zMadZzOggCiKO1gtMtY b2kDtqT1nf6s+0/VGp8lDyVn2Bcl2GZkGAmtXzdwegteRf504iTQPR9gr09DQzmwvQFD Gykuz2z7rbCLvfYv7CTbFlS09ATuNK4s3/cQkiKSz2p8ICIoGahLEaSN+zdQ9Aq6mn9X frSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=+mTfC4jDcvY6SxKy66SZlxX6jY/n0T7CqjBnsK5yJnU=; b=x5YL75gc73iLOCeTejS0UF1l7uYzr3hxaosKeCvBcY57LPlLEjIuiZrqWugjTH1xKI lbXQ2RJLO17tvY7rA9pxI96kDZ+Lg1anxe0MCn6HhTE7z1mfqQl2htP6xfEysg35arsz MIW7TvcJPMYKqlNYdm4xmPXoHjIGaBKKTJtGZNgVKRuAxHY1KtWPuKfeYP3kaJKzMJQ8 DDQSIV9bZzgAipXVIbdINuCE/YkQdWwFbUmr9xpyPjjYHisUFCuz1X/iOvKHeaVw2XYD 4KoJlaB2aaldIpeDTP0hlr2Q7qiiouKo/TZdP/Hk2pBA+6CmnRn3Ao03E6fghp3rSRmO +dEg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si10987590pgf.22.2018.12.10.17.17.20; Mon, 10 Dec 2018 17:17:36 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728755AbeLJVWn (ORCPT + 99 others); Mon, 10 Dec 2018 16:22:43 -0500 Received: from mga05.intel.com ([192.55.52.43]:40410 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728191AbeLJVWm (ORCPT ); Mon, 10 Dec 2018 16:22:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 13:22:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,339,1539673200"; d="scan'208";a="99626325" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga006.jf.intel.com with ESMTP; 10 Dec 2018 13:22:41 -0800 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: gavin.hindman@intel.com, jithu.joseph@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , stable@vger.kernel.org Subject: [PATCH V2] x86/intel_rdt: Ensure usage of CPUs are locked while needed Date: Mon, 10 Dec 2018 13:21:54 -0800 Message-Id: X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The user triggers the creation of a pseudo-locked region when writing the requested schemata to the schemata resctrl file. The pseudo-locking of a region is required to be done on a CPU that is associated with the cache on which the pseudo-locked region will reside. In order to run the locking code on a specific CPU the needed CPU has to be selected and ensured to remain online during the entire locking sequence. At this time the cpu_hotplug_lock is not taken during the pseudo-lock region creation and it is thus possible for a CPU to be selected to run the pseudo-locking code and then that CPU to go offline before the thread is able to run on it. Fix this by ensuring that the cpu_hotplug_lock is taken while the CPU on which code has to run needs to be controlled. Since the cpu_hotplug_lock is always taken before rdtgroup_mutex the lock order is maintained. Fixes: e0bdfe8e36f3 ("x86/intel_rdt: Support creation/removal of pseudo-locked region") Signed-off-by: Reinette Chatre Cc: stable@vger.kernel.org --- V2: - Rebase against tip/x86/urgent - Modify subject from x86/resctrl to x86/intel_rdt to match subject used before the code reorganization. arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c index 27937458c231..efa4a519f5e5 100644 --- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c +++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c @@ -23,6 +23,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -310,9 +311,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, return -EINVAL; buf[nbytes - 1] = '\0'; + cpus_read_lock(); rdtgrp = rdtgroup_kn_lock_live(of->kn); if (!rdtgrp) { rdtgroup_kn_unlock(of->kn); + cpus_read_unlock(); return -ENOENT; } rdt_last_cmd_clear(); @@ -367,6 +370,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, out: rdtgroup_kn_unlock(of->kn); + cpus_read_unlock(); return ret ?: nbytes; } -- 2.17.0