Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Qiuxu Zhuo and committed by
Borislav Petkov (AMD)
325c3376 81983758

+2 -9
+2 -9
arch/x86/kernel/cpu/mce/dev-mcelog.c
··· 264 264 return put_user(sizeof(struct mce), p); 265 265 case MCE_GET_LOG_LEN: 266 266 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); 276 269 default: 277 270 return -ENOTTY; 278 271 }