Received: by 10.223.185.116 with SMTP id b49csp28430wrg; Tue, 13 Feb 2018 15:55:55 -0800 (PST) X-Google-Smtp-Source: AH8x225aJZxAM7A21I2P94jdW1A3HfvziWfi51x/mXcUo+bhYBpUoa+hgRlifCH1MM97iME2XaBr X-Received: by 10.99.161.26 with SMTP id b26mr2353603pgf.130.1518566155531; Tue, 13 Feb 2018 15:55:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518566155; cv=none; d=google.com; s=arc-20160816; b=UBFo8GWIEaJ0NXeTRq/HIngc+iR9Dsr5SiN0HMR8dWluuvc3pYhI7Jwwc12awRr7X7 aqmGPHApmeiuYDyeOH2cvvZny4qocR7hs8FjvSdM3hH8EJedNpqsNL/7gi69Ofj2CsSU IbJPZ1woY+cstpbGXOX9He7YyA+s37FtNEpkHx4W9iy9+S9HR5djcSe85R95LsY3zJfw Q/E4HDY9TF6jln2TGVP5SZ8VvVXyzhi0tK8AAKi/kKZKMVcbZuO1JmyAEj/M/wn/+C0+ eR3HOu37GsSZMawfkPdedc1Oq0fVBQ7EghOrK+eJTZbRgRuUdepcGEZaTASfS/ckMsdV sAZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BovwRsEYR0xCEoi1Irpp1lVHrteSheTVmnHJhcLsJ1I=; b=KOfcTXewjCFYg+1j6KuKr4bOEfQXT9vTPi0SxAwtdXUUiAER3teGJOhUumyidT6dzo R+5upwpIeA9PJSRSnfUfYgMFZOi/qWlxovUjKVwd+lozU3x7x1u5/VqiSoEYljK7/wi9 b4lKAWPq42QM6R8nmWFpp8mXsjsiE0gZjU1n56+UDm1XFJWpTf9fDhY6FLcCLlK9Za0s uCbsgnqgFfblsD1cPp5EP/l7C0hjjd6lRavkb6Vn8qJEbz8d3kkxnu8FlH+9uEXvzoDF tnYZLpB0guuVSK0fwmAS/AyYFDtr05xqTtg0R8ayg1xHwUypTq5Jlsh7g8Sh8Y+soKGn VHPQ== 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 s24si141293pgv.779.2018.02.13.15.55.41; Tue, 13 Feb 2018 15:55:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966302AbeBMXyT (ORCPT + 99 others); Tue, 13 Feb 2018 18:54:19 -0500 Received: from mga17.intel.com ([192.55.52.151]:53392 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966125AbeBMXtd (ORCPT ); Tue, 13 Feb 2018 18:49:33 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2018 15:49:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,509,1511856000"; d="scan'208";a="29822302" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga004.fm.intel.com with ESMTP; 13 Feb 2018 15:49:32 -0800 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com Cc: gavin.hindman@intel.com, vikas.shivappa@linux.intel.com, dave.hansen@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [RFC PATCH V2 03/22] x86/intel_rdt: Introduce hooks to create pseudo-locking files Date: Tue, 13 Feb 2018 07:46:47 -0800 Message-Id: <1c827e6bb424e94f7ddbf7bf323c4fc4e93ee6af.1518443616.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We create a new file to host pseudo-locking specific code. The first of this code are the functions that create the initial pseudo_lock directory with its first file, "avail", starting by reporting zero. This will be expanded in future commits. Signed-off-by: Reinette Chatre --- arch/x86/kernel/cpu/Makefile | 3 +- arch/x86/kernel/cpu/intel_rdt.h | 2 + arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 105 ++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile index 570e8bb1f386..53022c2413e0 100644 --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile @@ -35,7 +35,8 @@ obj-$(CONFIG_CPU_SUP_CENTAUR) += centaur.o obj-$(CONFIG_CPU_SUP_TRANSMETA_32) += transmeta.o obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o -obj-$(CONFIG_INTEL_RDT) += intel_rdt.o intel_rdt_rdtgroup.o intel_rdt_monitor.o intel_rdt_ctrlmondata.o +obj-$(CONFIG_INTEL_RDT) += intel_rdt.o intel_rdt_rdtgroup.o intel_rdt_monitor.o +obj-$(CONFIG_INTEL_RDT) += intel_rdt_ctrlmondata.o intel_rdt_pseudo_lock.o obj-$(CONFIG_X86_MCE) += mcheck/ obj-$(CONFIG_MTRR) += mtrr/ diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index df4db23ddd74..146a8090bb58 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -454,5 +454,7 @@ void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms); void cqm_handle_limbo(struct work_struct *work); bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d); void __check_limbo(struct rdt_domain *d, bool force_free); +int rdt_pseudo_lock_fs_init(struct kernfs_node *root); +void rdt_pseudo_lock_fs_remove(void); #endif /* _ASM_X86_INTEL_RDT_H */ diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c new file mode 100644 index 000000000000..ad8b97747024 --- /dev/null +++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c @@ -0,0 +1,105 @@ +/* + * Resource Director Technology(RDT) + * + * Pseudo-locking support built on top of Cache Allocation Technology (CAT) + * + * Copyright (C) 2017 Intel Corporation + * + * Author: Reinette Chatre + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include "intel_rdt.h" + +static struct kernfs_node *pseudo_lock_kn; + +static int pseudo_lock_avail_show(struct seq_file *sf, void *v) +{ + seq_puts(sf, "0\n"); + return 0; +} + +static struct kernfs_ops pseudo_lock_avail_ops = { + .seq_show = pseudo_lock_avail_show, +}; + +/** + * rdt_pseudo_lock_fs_init - Create and initialize pseudo-locking files + * @root: location in kernfs where directory and files should be created + * + * The pseudo_lock directory and the pseudo-locking related files and + * directories will live within the structure created here. + * + * LOCKING: + * rdtgroup_mutex is expected to be held when called + * + * RETURNS: + * 0 on success, -errno on failure + */ +int rdt_pseudo_lock_fs_init(struct kernfs_node *root) +{ + struct kernfs_node *kn; + int ret; + + lockdep_assert_held(&rdtgroup_mutex); + + pseudo_lock_kn = kernfs_create_dir(root, "pseudo_lock", + root->mode, NULL); + if (IS_ERR(pseudo_lock_kn)) + return PTR_ERR(pseudo_lock_kn); + + kn = __kernfs_create_file(pseudo_lock_kn, "avail", 0444, + 0, &pseudo_lock_avail_ops, + NULL, NULL, NULL); + if (IS_ERR(kn)) { + ret = PTR_ERR(kn); + goto error; + } + + ret = rdtgroup_kn_set_ugid(pseudo_lock_kn); + if (ret) + goto error; + + kernfs_activate(pseudo_lock_kn); + + ret = 0; + goto out; + +error: + kernfs_remove(pseudo_lock_kn); + pseudo_lock_kn = NULL; +out: + return ret; +} + +/** + * rdt_pseudo_lock_fs_remove - Remove all pseudo-locking files + * + * All pseudo-locking related files and directories are removed. + * + * LOCKING: + * rdtgroup_mutex is expected to be held when called + * + * RETURNS: + * none + */ +void rdt_pseudo_lock_fs_remove(void) +{ + lockdep_assert_held(&rdtgroup_mutex); + + kernfs_remove(pseudo_lock_kn); + pseudo_lock_kn = NULL; +} -- 2.13.6