Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1498164imu; Wed, 28 Nov 2018 10:23:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WntytAK+1xx6lN8us2gQreuutSIkmcbqNPGHAoB9pI0XFrN8Wajo1gSIOAINqE4aaRZwJJ X-Received: by 2002:a17:902:28e6:: with SMTP id f93mr32198908plb.239.1543429438526; Wed, 28 Nov 2018 10:23:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543429438; cv=none; d=google.com; s=arc-20160816; b=F+pj4+M3P/XNc1rYmB65gvAYSM/e6y1oWr6vpXR1GpSzBwgz3bgiIJI3hkb0feBBwQ sML/hzZe37aHOP87Etm0ncNfqAPnzZD4sFD0B/QzFRaU2dF6RQ0YUXaNNSF18RGAheil OGRw4Ht90p8PqQGVJN8VlhsWbNRRlo6/5rQknfYLVNsNO/jqRs56wLYHwK/xt/a4/r4/ Vxzll7uRnqWA0I61TBW7rHWnuTM3dljWxVZGumJ3z6Kqw4bj3DINJsUYuhuxDw25eMOR kd27kP/3OwOtMUba48rxNT3vr/cf4+C3226IAnCz8AAGWqQPd+pVpPAQWW37yjCMQEDD 5/rw== 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=PStaAvcrQlat4NyjTfjzWgNXMlpcZkctR/HC3Cvu4cs=; b=e2WjxWH8DWOr8hxCfdvpsYTMJXkEnXnTsctAF6TJvAWKfwy5kDQim2FDkiOJ208sSd U1lAont/7xa0ijVFQySZ8r3rWSxl2SxmnO7eBtmGYXcWzRztkjumdQ9JJVbbtm2l23jX qknFRjB55smHwBuPChgmFA7E6AoMeiOqmaDGDUdnzEGZFVluip5XScDJ2UpA7QLCDBAE Hr7eu5x3rS0Ax5v8jBitWMNmL9Yt0Yn8h3vTnOGD6x8FDCRpnQqj9C7t2RywjJhkBBQE bPtGDIJcSje8zANzGqZfArP4LClGjcF613P4SBwp9rDZZFrK3166+w3L1Pi+Fez+nmAy 3y6g== 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 59-v6si8208460plb.75.2018.11.28.10.23.38; Wed, 28 Nov 2018 10:23:58 -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 S1727508AbeK2FZc (ORCPT + 99 others); Thu, 29 Nov 2018 00:25:32 -0500 Received: from mga18.intel.com ([134.134.136.126]:30896 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725266AbeK2FZb (ORCPT ); Thu, 29 Nov 2018 00:25:31 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Nov 2018 10:22:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,291,1539673200"; d="scan'208";a="278352141" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga005.jf.intel.com with ESMTP; 28 Nov 2018 10:22:59 -0800 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: 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] x86/resctrl: Ensure usage of CPUs are locked while needed Date: Wed, 28 Nov 2018 10:22:07 -0800 Message-Id: <725073a1f4448e3c45ed7102229e6946ca2526d8.1543428144.git.reinette.chatre@intel.com> 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 --- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c index 03ee13235a45..6f7adb3be01e 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -23,6 +23,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -381,9 +382,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(); @@ -438,6 +441,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