View | Details | Raw Unified | Return to bug 1222241
Collapse All | Expand All

(-)file_not_specified_in_diff (-16 / +26 lines)
Line  Link Here
 with max_t(int) for fixing build errors -- tiwai ]
 with max_t(int) for fixing build errors -- tiwai ]
1
 [ bp: Rename local var from tmpp to something more telling: gpool. ]
1
 [ bp: Rename local var from tmpp to something more telling: gpool. ]
2
--
3
arch/x86/kernel/cpu/mce/genpool.c |   39 ++++++++++++++++++++++++--------------
2
arch/x86/kernel/cpu/mce/genpool.c |   39 ++++++++++++++++++++++++--------------
4
1 file changed, 25 insertions(+), 14 deletions(-)
3
1 file changed, 25 insertions(+), 14 deletions(-)
5
-- a/arch/x86/kernel/cpu/mce/genpool.c
4
++ b/arch/x86/kernel/cpu/mce/genpool.c
Lines 9-14 Link Here
9
#include <linux/mm.h>
9
#include <linux/mm.h>
10
#include <linux/genalloc.h>
10
#include <linux/genalloc.h>
11
#include <linux/llist.h>
11
#include <linux/llist.h>
12
#include <linux/slab.h>
12
#include "internal.h"
13
#include "internal.h"
13
14
14
/*
15
/*
Lines 16-29 Link Here
16
 * used to save error information organized in a lock-less list.
17
 * used to save error information organized in a lock-less list.
17
 *
18
 *
18
 * This memory pool is only to be used to save MCE records in MCE context.
19
 * This memory pool is only to be used to save MCE records in MCE context.
19
 * MCE events are rare, so a fixed size memory pool should be enough. Use
20
 * MCE events are rare, so a fixed size memory pool should be enough.
20
 * 2 pages to save MCE events for now (~80 MCE records at most).
21
 * Allocate on a sliding scale based on number of CPUs.
21
 */
22
 */
22
#define MCE_POOLSZ	(2 * PAGE_SIZE)
23
#define MCE_MIN_ENTRIES	80
24
#define MCE_PER_CPU	2
23
25
24
static struct gen_pool *mce_evt_pool;
26
static struct gen_pool *mce_evt_pool;
25
static LLIST_HEAD(mce_event_llist);
27
static LLIST_HEAD(mce_event_llist);
26
static char gen_pool_buf[MCE_POOLSZ];
27
28
28
/*
29
/*
29
 * Compare the record "t" with each of the records on list "l" to see if
30
 * Compare the record "t" with each of the records on list "l" to see if
Lines 118-139 int mce_gen_pool_add(struct mce *mce) Link Here
118
119
119
static int mce_gen_pool_create(void)
120
static int mce_gen_pool_create(void)
120
{
121
{
121
	struct gen_pool *tmpp;
122
	int mce_numrecords, mce_poolsz, order;
123
	struct gen_pool *gpool;
122
	int ret = -ENOMEM;
124
	int ret = -ENOMEM;
125
	void *mce_pool;
123
126
124
	tmpp = gen_pool_create(ilog2(sizeof(struct mce_evt_llist)), -1);
127
	order = order_base_2(sizeof(struct mce_evt_llist));
125
	if (!tmpp)
128
	gpool = gen_pool_create(order, -1);
126
		goto out;
129
	if (!gpool)
127
130
		return ret;
128
	ret = gen_pool_add(tmpp, (unsigned long)gen_pool_buf, MCE_POOLSZ, -1);
131
132
	mce_numrecords = max_t(int, MCE_MIN_ENTRIES, num_possible_cpus() * MCE_PER_CPU);
133
	mce_poolsz = mce_numrecords * (1 << order);
134
	mce_pool = kmalloc(mce_poolsz, GFP_KERNEL);
135
	if (!mce_pool) {
136
		gen_pool_destroy(gpool);
137
		return ret;
138
	}
139
	ret = gen_pool_add(gpool, (unsigned long)mce_pool, mce_poolsz, -1);
129
	if (ret) {
140
	if (ret) {
130
		gen_pool_destroy(tmpp);
141
		gen_pool_destroy(gpool);
131
		goto out;
142
		kfree(mce_pool);
143
		return ret;
132
	}
144
	}
133
145
134
	mce_evt_pool = tmpp;
146
	mce_evt_pool = gpool;
135
147
136
out:
137
	return ret;
148
	return ret;
138
}
149
}
139
150

Return to bug 1222241