Skip to content

Commit 325c337

Browse files
qzhuo2bp3tk0v
authored andcommitted
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 <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Tony Luck <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Sohil Mehta <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8198375 commit 325c337

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)