Skip to content

Commit 403181e

Browse files
committed
x86/mce/mcelog: Use xchg() to get and clear the flags
JIRA: https://issues.redhat.com/browse/RHEL-118444 commit 325c337 Author: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Date: Fri Oct 25 10:45:53 2024 +0800 x86/mce/mcelog: Use xchg() to get and clear the flags Using xchg() to atomically get and clear the MCE log buffer flags, streamlines the code and reduces the text size by 20 bytes. $ size dev-mcelog.o.* text data bss dec hex filename 3013 360 160 3533 dcd dev-mcelog.o.old 2993 360 160 3513 db9 dev-mcelog.o.new No functional changes intended. Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Reviewed-by: Sohil Mehta <sohil.mehta@intel.com> Link: https://lore.kernel.org/r/20241025024602.24318-2-qiuxu.zhuo@intel.com Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 655dc8b commit 403181e

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

arch/x86/kernel/cpu/mce/dev-mcelog.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,8 @@ static long mce_chrdev_ioctl(struct file *f, unsigned int cmd,
264264
return put_user(sizeof(struct mce), p);
265265
case MCE_GET_LOG_LEN:
266266
return put_user(mcelog->len, p);
267-
case MCE_GETCLEAR_FLAGS: {
268-
unsigned flags;
269-
270-
do {
271-
flags = mcelog->flags;
272-
} while (cmpxchg(&mcelog->flags, flags, 0) != flags);
273-
274-
return put_user(flags, p);
275-
}
267+
case MCE_GETCLEAR_FLAGS:
268+
return put_user(xchg(&mcelog->flags, 0), p);
276269
default:
277270
return -ENOTTY;
278271
}

0 commit comments

Comments
 (0)