From: kan.liang@intel.com
To: peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com,
linux-kernel@vger.kernel.org
Cc: bp@alien8.de, acme@kernel.org, eranian@google.com,
jolsa@kernel.org, ak@linux.intel.com,
Kan Liang <Kan.liang@intel.com>
Subject: [PATCH V4 1/2] x86/msr: expose msr_flip_bit function
Date: Tue, 28 Mar 2017 18:45:19 -0700 [thread overview]
Message-ID: <1490751920-44720-2-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1490751920-44720-1-git-send-email-kan.liang@intel.com>
From: Kan Liang <Kan.liang@intel.com>
There is no exported kernel interfaces which can flip a MSR bit. It has
to do read-modify-write operation on the MSR through rd/wrmsr*
interfaces. But the method is not atomic.
There is already __flip_bit support. Just rename and expose it.
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kan Liang <Kan.liang@intel.com>
---
arch/x86/include/asm/msr.h | 1 +
arch/x86/lib/msr.c | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 898dba2..c1e3026 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -312,6 +312,7 @@ struct msr *msrs_alloc(void);
void msrs_free(struct msr *msrs);
int msr_set_bit(u32 msr, u8 bit);
int msr_clear_bit(u32 msr, u8 bit);
+int msr_flip_bit(u32 msr, u8 bit, bool set);
#ifdef CONFIG_SMP
int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c
index 0776425..9bda539 100644
--- a/arch/x86/lib/msr.c
+++ b/arch/x86/lib/msr.c
@@ -58,7 +58,7 @@ int msr_write(u32 msr, struct msr *m)
return wrmsrl_safe(msr, m->q);
}
-static inline int __flip_bit(u32 msr, u8 bit, bool set)
+int msr_flip_bit(u32 msr, u8 bit, bool set)
{
struct msr m, m1;
int err = -EINVAL;
@@ -85,6 +85,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set)
return 1;
}
+EXPORT_SYMBOL_GPL(msr_flip_bit);
/**
* Set @bit in a MSR @msr.
@@ -96,7 +97,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set)
*/
int msr_set_bit(u32 msr, u8 bit)
{
- return __flip_bit(msr, bit, true);
+ return msr_flip_bit(msr, bit, true);
}
/**
@@ -109,7 +110,7 @@ int msr_set_bit(u32 msr, u8 bit)
*/
int msr_clear_bit(u32 msr, u8 bit)
{
- return __flip_bit(msr, bit, false);
+ return msr_flip_bit(msr, bit, false);
}
#ifdef CONFIG_TRACEPOINTS
--
2.7.4
next prev parent reply other threads:[~2017-03-29 2:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 1:45 [PATCH V4 0/2] measure SMI cost (kernel) kan.liang
2017-03-29 1:45 ` kan.liang [this message]
2017-03-29 5:47 ` [PATCH V4 1/2] x86/msr: expose msr_flip_bit function Thomas Gleixner
2017-03-29 13:01 ` Liang, Kan
2017-03-29 1:45 ` [PATCH V4 2/2] perf/x86: add sysfs entry to freeze counter on SMI kan.liang
2017-03-29 4:18 ` Andi Kleen
2017-03-29 6:00 ` Thomas Gleixner
2017-03-29 6:24 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490751920-44720-2-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=bp@alien8.de \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox