mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-14 01:10:15 +08:00
ZONE(9): Fix UMA_PCPU_ALLOC_SIZE
Using CACHE_LINE_SIZE for UMA_PCPU_ALLOC_SIZE was a huge memory waste since the backend memory allocator is page based.
This commit is contained in:
parent
1c3a92d81e
commit
b3bbfdfe91
@ -170,6 +170,7 @@ extern uintptr_t dpcpu_off[];
|
|||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
/*
|
/*
|
||||||
* This structure maps out the global data that needs to be kept on a
|
* This structure maps out the global data that needs to be kept on a
|
||||||
* per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR
|
* per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR
|
||||||
@ -177,7 +178,6 @@ extern uintptr_t dpcpu_off[];
|
|||||||
* defined in the PCPU_MD_FIELDS macro defined in <machine/pcpu.h>.
|
* defined in the PCPU_MD_FIELDS macro defined in <machine/pcpu.h>.
|
||||||
*/
|
*/
|
||||||
struct pcpu {
|
struct pcpu {
|
||||||
#ifndef __rtems__
|
|
||||||
struct thread *pc_curthread; /* Current thread */
|
struct thread *pc_curthread; /* Current thread */
|
||||||
struct thread *pc_idlethread; /* Idle thread */
|
struct thread *pc_idlethread; /* Idle thread */
|
||||||
struct thread *pc_fpcurthread; /* Fp state owner */
|
struct thread *pc_fpcurthread; /* Fp state owner */
|
||||||
@ -208,10 +208,10 @@ struct pcpu {
|
|||||||
* if only to make kernel debugging easier.
|
* if only to make kernel debugging easier.
|
||||||
*/
|
*/
|
||||||
PCPU_MD_FIELDS;
|
PCPU_MD_FIELDS;
|
||||||
#else /* __rtems__ */
|
|
||||||
int pc_dummy;
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
} __aligned(CACHE_LINE_SIZE);
|
} __aligned(CACHE_LINE_SIZE);
|
||||||
|
#else /* __rtems__ */
|
||||||
|
struct pcpu;
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
|
||||||
@ -227,9 +227,9 @@ extern struct pcpu *cpuid_to_pcpu[];
|
|||||||
#endif
|
#endif
|
||||||
#define curvidata PCPU_GET(vidata)
|
#define curvidata PCPU_GET(vidata)
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
#define UMA_PCPU_ALLOC_SIZE PAGE_SIZE
|
#define UMA_PCPU_ALLOC_SIZE PAGE_SIZE
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
#ifdef CTASSERT
|
#ifdef CTASSERT
|
||||||
#if defined(__i386__) || defined(__amd64__)
|
#if defined(__i386__) || defined(__amd64__)
|
||||||
/* Required for counters(9) to work on x86. */
|
/* Required for counters(9) to work on x86. */
|
||||||
@ -242,8 +242,6 @@ CTASSERT(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE);
|
|||||||
CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE);
|
CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE);
|
||||||
#endif /* UMA_PCPU_ALLOC_SIZE && x86 */
|
#endif /* UMA_PCPU_ALLOC_SIZE && x86 */
|
||||||
#endif /* CTASSERT */
|
#endif /* CTASSERT */
|
||||||
#else /* __rtems__ */
|
|
||||||
#define UMA_PCPU_ALLOC_SIZE sizeof(struct pcpu)
|
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
|
/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */
|
||||||
|
@ -42,7 +42,7 @@ static inline uint64_t
|
|||||||
counter_u64_read_one(uint64_t *p, int cpu)
|
counter_u64_read_one(uint64_t *p, int cpu)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (*((uint64_t *)((char *)p + sizeof(struct pcpu) * cpu)));
|
return (*((uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t
|
static inline uint64_t
|
||||||
@ -65,7 +65,7 @@ counter_u64_zero_inline(counter_u64_t c)
|
|||||||
uint32_t cpu;
|
uint32_t cpu;
|
||||||
|
|
||||||
for (cpu = 0; cpu < _SMP_Get_processor_count(); ++cpu) {
|
for (cpu = 0; cpu < _SMP_Get_processor_count(); ++cpu) {
|
||||||
*((uint64_t *)((char *)c + sizeof(struct pcpu) * cpu)) = 0;
|
*((uint64_t *)((char *)c + UMA_PCPU_ALLOC_SIZE * cpu)) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user