Commit b4864f65 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'ras_core_for_v6.10_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull RAS update from Borislav Petkov:

 - Change the fixed-size buffer for MCE records to a dynamically sized
   one based on the number of CPUs present in the system

* tag 'ras_core_for_v6.10_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/mce: Dynamically size space for machine check records
parents eba77c04 108c6494
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
* used to save error information organized in a lock-less list. * used to save error information organized in a lock-less list.
* *
* This memory pool is only to be used to save MCE records in MCE context. * This memory pool is only to be used to save MCE records in MCE context.
* MCE events are rare, so a fixed size memory pool should be enough. Use * MCE events are rare, so a fixed size memory pool should be enough.
* 2 pages to save MCE events for now (~80 MCE records at most). * Allocate on a sliding scale based on number of CPUs.
*/ */
#define MCE_POOLSZ (2 * PAGE_SIZE) #define MCE_MIN_ENTRIES 80
#define MCE_PER_CPU 2
static struct gen_pool *mce_evt_pool; static struct gen_pool *mce_evt_pool;
static LLIST_HEAD(mce_event_llist); static LLIST_HEAD(mce_event_llist);
static char gen_pool_buf[MCE_POOLSZ];
/* /*
* Compare the record "t" with each of the records on list "l" to see if * Compare the record "t" with each of the records on list "l" to see if
...@@ -118,22 +118,32 @@ int mce_gen_pool_add(struct mce *mce) ...@@ -118,22 +118,32 @@ int mce_gen_pool_add(struct mce *mce)
static int mce_gen_pool_create(void) static int mce_gen_pool_create(void)
{ {
struct gen_pool *tmpp; int mce_numrecords, mce_poolsz, order;
struct gen_pool *gpool;
int ret = -ENOMEM; int ret = -ENOMEM;
void *mce_pool;
tmpp = gen_pool_create(ilog2(sizeof(struct mce_evt_llist)), -1);
if (!tmpp) order = order_base_2(sizeof(struct mce_evt_llist));
goto out; gpool = gen_pool_create(order, -1);
if (!gpool)
ret = gen_pool_add(tmpp, (unsigned long)gen_pool_buf, MCE_POOLSZ, -1); return ret;
mce_numrecords = max(MCE_MIN_ENTRIES, num_possible_cpus() * MCE_PER_CPU);
mce_poolsz = mce_numrecords * (1 << order);
mce_pool = kmalloc(mce_poolsz, GFP_KERNEL);
if (!mce_pool) {
gen_pool_destroy(gpool);
return ret;
}
ret = gen_pool_add(gpool, (unsigned long)mce_pool, mce_poolsz, -1);
if (ret) { if (ret) {
gen_pool_destroy(tmpp); gen_pool_destroy(gpool);
goto out; kfree(mce_pool);
return ret;
} }
mce_evt_pool = tmpp; mce_evt_pool = gpool;
out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment