Skip to content

Commit bb3860c

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/nmi: get rid of private slab cache
Get rid of private "nmi_save_areas" slab cache. The only reason this was introduced years ago was that with some slab debugging options allocations would only guarantee a minimum alignment of ARCH_KMALLOC_MINALIGN, which was eight bytes back then. This is not sufficient for the extended machine check save area. However since commit 59bb479 ("mm, sl[aou]b: guarantee natural alignment for kmalloc(power-of-two)") kmalloc guarantees a power-of-two alignment even with debugging options enabled. Therefore the private slab cache can be removed. Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 742aed0 commit bb3860c

1 file changed

Lines changed: 9 additions & 31 deletions

File tree

arch/s390/kernel/nmi.c

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,12 @@ struct mcck_struct {
4242
};
4343

4444
static DEFINE_PER_CPU(struct mcck_struct, cpu_mcck);
45-
static struct kmem_cache *mcesa_cache;
46-
static unsigned long mcesa_origin_lc;
4745

4846
static inline int nmi_needs_mcesa(void)
4947
{
5048
return MACHINE_HAS_VX || MACHINE_HAS_GS;
5149
}
5250

53-
static inline unsigned long nmi_get_mcesa_size(void)
54-
{
55-
if (MACHINE_HAS_GS)
56-
return MCESA_MAX_SIZE;
57-
return MCESA_MIN_SIZE;
58-
}
59-
6051
/*
6152
* The initial machine check extended save area for the boot CPU.
6253
* It will be replaced on the boot CPU reinit with an allocated
@@ -74,44 +65,31 @@ void __init nmi_alloc_mcesa_early(u64 *mcesad)
7465
*mcesad |= ilog2(MCESA_MAX_SIZE);
7566
}
7667

77-
static void __init nmi_alloc_cache(void)
68+
int nmi_alloc_mcesa(u64 *mcesad)
7869
{
7970
unsigned long size;
80-
81-
if (!nmi_needs_mcesa())
82-
return;
83-
size = nmi_get_mcesa_size();
84-
if (size > MCESA_MIN_SIZE)
85-
mcesa_origin_lc = ilog2(size);
86-
/* create slab cache for the machine-check-extended-save-areas */
87-
mcesa_cache = kmem_cache_create("nmi_save_areas", size, size, 0, NULL);
88-
if (!mcesa_cache)
89-
panic("Couldn't create nmi save area cache");
90-
}
91-
92-
int __ref nmi_alloc_mcesa(u64 *mcesad)
93-
{
94-
unsigned long origin;
71+
void *origin;
9572

9673
*mcesad = 0;
9774
if (!nmi_needs_mcesa())
9875
return 0;
99-
if (!mcesa_cache)
100-
nmi_alloc_cache();
101-
origin = (unsigned long) kmem_cache_alloc(mcesa_cache, GFP_KERNEL);
76+
size = MACHINE_HAS_GS ? MCESA_MAX_SIZE : MCESA_MIN_SIZE;
77+
origin = kmalloc(size, GFP_KERNEL);
10278
if (!origin)
10379
return -ENOMEM;
10480
/* The pointer is stored with mcesa_bits ORed in */
105-
kmemleak_not_leak((void *) origin);
106-
*mcesad = __pa(origin) | mcesa_origin_lc;
81+
kmemleak_not_leak(origin);
82+
*mcesad = __pa(origin);
83+
if (MACHINE_HAS_GS)
84+
*mcesad |= ilog2(MCESA_MAX_SIZE);
10785
return 0;
10886
}
10987

11088
void nmi_free_mcesa(u64 *mcesad)
11189
{
11290
if (!nmi_needs_mcesa())
11391
return;
114-
kmem_cache_free(mcesa_cache, __va(*mcesad & MCESA_ORIGIN_MASK));
92+
kfree(__va(*mcesad & MCESA_ORIGIN_MASK));
11593
}
11694

11795
static __always_inline char *nmi_puts(char *dest, const char *src)

0 commit comments

Comments
 (0)