Skip to content

Commit d0e0ac9

Browse files
Chen Gangpenberg
authored andcommitted
mm/slub: beautify code for 80 column limitation and tab alignment
Be sure of 80 column limitation for both code and comments. Correct tab alignment for 'if-else' statement. Acked-by: Christoph Lameter <cl@linux.com> Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
1 parent e35e1a9 commit d0e0ac9

1 file changed

Lines changed: 56 additions & 36 deletions

File tree

‎mm/slub.c‎

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ static inline bool __cmpxchg_double_slab(struct kmem_cache *s, struct page *page
373373
#endif
374374
{
375375
slab_lock(page);
376-
if (page->freelist == freelist_old && page->counters == counters_old) {
376+
if (page->freelist == freelist_old &&
377+
page->counters == counters_old) {
377378
page->freelist = freelist_new;
378379
page->counters = counters_new;
379380
slab_unlock(page);
@@ -411,7 +412,8 @@ static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct page *page,
411412

412413
local_irq_save(flags);
413414
slab_lock(page);
414-
if (page->freelist == freelist_old && page->counters == counters_old) {
415+
if (page->freelist == freelist_old &&
416+
page->counters == counters_old) {
415417
page->freelist = freelist_new;
416418
page->counters = counters_new;
417419
slab_unlock(page);
@@ -553,8 +555,9 @@ static void print_tracking(struct kmem_cache *s, void *object)
553555

554556
static void print_page_info(struct page *page)
555557
{
556-
printk(KERN_ERR "INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n",
557-
page, page->objects, page->inuse, page->freelist, page->flags);
558+
printk(KERN_ERR
559+
"INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n",
560+
page, page->objects, page->inuse, page->freelist, page->flags);
558561

559562
}
560563

@@ -629,7 +632,8 @@ static void object_err(struct kmem_cache *s, struct page *page,
629632
print_trailer(s, page, object);
630633
}
631634

632-
static void slab_err(struct kmem_cache *s, struct page *page, const char *fmt, ...)
635+
static void slab_err(struct kmem_cache *s, struct page *page,
636+
const char *fmt, ...)
633637
{
634638
va_list args;
635639
char buf[100];
@@ -788,7 +792,8 @@ static int check_object(struct kmem_cache *s, struct page *page,
788792
} else {
789793
if ((s->flags & SLAB_POISON) && s->object_size < s->inuse) {
790794
check_bytes_and_report(s, page, p, "Alignment padding",
791-
endobject, POISON_INUSE, s->inuse - s->object_size);
795+
endobject, POISON_INUSE,
796+
s->inuse - s->object_size);
792797
}
793798
}
794799

@@ -918,7 +923,8 @@ static void trace(struct kmem_cache *s, struct page *page, void *object,
918923
page->freelist);
919924

920925
if (!alloc)
921-
print_section("Object ", (void *)object, s->object_size);
926+
print_section("Object ", (void *)object,
927+
s->object_size);
922928

923929
dump_stack();
924930
}
@@ -937,7 +943,8 @@ static inline int slab_pre_alloc_hook(struct kmem_cache *s, gfp_t flags)
937943
return should_failslab(s->object_size, flags, s->flags);
938944
}
939945

940-
static inline void slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags, void *object)
946+
static inline void slab_post_alloc_hook(struct kmem_cache *s,
947+
gfp_t flags, void *object)
941948
{
942949
flags &= gfp_allowed_mask;
943950
kmemcheck_slab_alloc(s, flags, object, slab_ksize(s));
@@ -1039,7 +1046,8 @@ static void setup_object_debug(struct kmem_cache *s, struct page *page,
10391046
init_tracking(s, object);
10401047
}
10411048

1042-
static noinline int alloc_debug_processing(struct kmem_cache *s, struct page *page,
1049+
static noinline int alloc_debug_processing(struct kmem_cache *s,
1050+
struct page *page,
10431051
void *object, unsigned long addr)
10441052
{
10451053
if (!check_slab(s, page))
@@ -1743,7 +1751,8 @@ static void init_kmem_cache_cpus(struct kmem_cache *s)
17431751
/*
17441752
* Remove the cpu slab
17451753
*/
1746-
static void deactivate_slab(struct kmem_cache *s, struct page *page, void *freelist)
1754+
static void deactivate_slab(struct kmem_cache *s, struct page *page,
1755+
void *freelist)
17471756
{
17481757
enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE };
17491758
struct kmem_cache_node *n = get_node(s, page_to_nid(page));
@@ -2002,7 +2011,8 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
20022011
page->pobjects = pobjects;
20032012
page->next = oldpage;
20042013

2005-
} while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page) != oldpage);
2014+
} while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page)
2015+
!= oldpage);
20062016
#endif
20072017
}
20082018

@@ -2172,8 +2182,8 @@ static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags)
21722182
}
21732183

21742184
/*
2175-
* Check the page->freelist of a page and either transfer the freelist to the per cpu freelist
2176-
* or deactivate the page.
2185+
* Check the page->freelist of a page and either transfer the freelist to the
2186+
* per cpu freelist or deactivate the page.
21772187
*
21782188
* The page is still frozen if the return value is not NULL.
21792189
*
@@ -2317,7 +2327,8 @@ static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
23172327
goto load_freelist;
23182328

23192329
/* Only entered in the debug case */
2320-
if (kmem_cache_debug(s) && !alloc_debug_processing(s, page, freelist, addr))
2330+
if (kmem_cache_debug(s) &&
2331+
!alloc_debug_processing(s, page, freelist, addr))
23212332
goto new_slab; /* Slab failed checks. Next slab needed */
23222333

23232334
deactivate_slab(s, page, get_freepointer(s, freelist));
@@ -2385,13 +2396,15 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s,
23852396
* The cmpxchg will only match if there was no additional
23862397
* operation and if we are on the right processor.
23872398
*
2388-
* The cmpxchg does the following atomically (without lock semantics!)
2399+
* The cmpxchg does the following atomically (without lock
2400+
* semantics!)
23892401
* 1. Relocate first pointer to the current per cpu area.
23902402
* 2. Verify that tid and freelist have not been changed
23912403
* 3. If they were not changed replace tid and freelist
23922404
*
2393-
* Since this is without lock semantics the protection is only against
2394-
* code executing on this cpu *not* from access by other cpus.
2405+
* Since this is without lock semantics the protection is only
2406+
* against code executing on this cpu *not* from access by
2407+
* other cpus.
23952408
*/
23962409
if (unlikely(!this_cpu_cmpxchg_double(
23972410
s->cpu_slab->freelist, s->cpu_slab->tid,
@@ -2423,7 +2436,8 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
24232436
{
24242437
void *ret = slab_alloc(s, gfpflags, _RET_IP_);
24252438

2426-
trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size, s->size, gfpflags);
2439+
trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size,
2440+
s->size, gfpflags);
24272441

24282442
return ret;
24292443
}
@@ -2515,8 +2529,10 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
25152529
if (kmem_cache_has_cpu_partial(s) && !prior)
25162530

25172531
/*
2518-
* Slab was on no list before and will be partially empty
2519-
* We can defer the list move and instead freeze it.
2532+
* Slab was on no list before and will be
2533+
* partially empty
2534+
* We can defer the list move and instead
2535+
* freeze it.
25202536
*/
25212537
new.frozen = 1;
25222538

@@ -3074,8 +3090,8 @@ static int kmem_cache_open(struct kmem_cache *s, unsigned long flags)
30743090
* A) The number of objects from per cpu partial slabs dumped to the
30753091
* per node list when we reach the limit.
30763092
* B) The number of objects in cpu partial slabs to extract from the
3077-
* per node list when we run out of per cpu objects. We only fetch 50%
3078-
* to keep some capacity around for frees.
3093+
* per node list when we run out of per cpu objects. We only fetch
3094+
* 50% to keep some capacity around for frees.
30793095
*/
30803096
if (!kmem_cache_has_cpu_partial(s))
30813097
s->cpu_partial = 0;
@@ -3102,8 +3118,8 @@ static int kmem_cache_open(struct kmem_cache *s, unsigned long flags)
31023118
if (flags & SLAB_PANIC)
31033119
panic("Cannot create slab %s size=%lu realsize=%u "
31043120
"order=%u offset=%u flags=%lx\n",
3105-
s->name, (unsigned long)s->size, s->size, oo_order(s->oo),
3106-
s->offset, flags);
3121+
s->name, (unsigned long)s->size, s->size,
3122+
oo_order(s->oo), s->offset, flags);
31073123
return -EINVAL;
31083124
}
31093125

@@ -3341,7 +3357,8 @@ bool verify_mem_not_deleted(const void *x)
33413357

33423358
slab_lock(page);
33433359
if (on_freelist(page->slab_cache, page, object)) {
3344-
object_err(page->slab_cache, page, object, "Object is on free-list");
3360+
object_err(page->slab_cache, page, object,
3361+
"Object is on free-list");
33453362
rv = false;
33463363
} else {
33473364
rv = true;
@@ -4165,15 +4182,17 @@ static int list_locations(struct kmem_cache *s, char *buf,
41654182
!cpumask_empty(to_cpumask(l->cpus)) &&
41664183
len < PAGE_SIZE - 60) {
41674184
len += sprintf(buf + len, " cpus=");
4168-
len += cpulist_scnprintf(buf + len, PAGE_SIZE - len - 50,
4185+
len += cpulist_scnprintf(buf + len,
4186+
PAGE_SIZE - len - 50,
41694187
to_cpumask(l->cpus));
41704188
}
41714189

41724190
if (nr_online_nodes > 1 && !nodes_empty(l->nodes) &&
41734191
len < PAGE_SIZE - 60) {
41744192
len += sprintf(buf + len, " nodes=");
4175-
len += nodelist_scnprintf(buf + len, PAGE_SIZE - len - 50,
4176-
l->nodes);
4193+
len += nodelist_scnprintf(buf + len,
4194+
PAGE_SIZE - len - 50,
4195+
l->nodes);
41774196
}
41784197

41794198
len += sprintf(buf + len, "\n");
@@ -4280,7 +4299,8 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
42804299
int cpu;
42814300

42824301
for_each_possible_cpu(cpu) {
4283-
struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu);
4302+
struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab,
4303+
cpu);
42844304
int node;
42854305
struct page *page;
42864306

@@ -4314,12 +4334,11 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
43144334
for_each_node_state(node, N_NORMAL_MEMORY) {
43154335
struct kmem_cache_node *n = get_node(s, node);
43164336

4317-
if (flags & SO_TOTAL)
4318-
x = atomic_long_read(&n->total_objects);
4319-
else if (flags & SO_OBJECTS)
4320-
x = atomic_long_read(&n->total_objects) -
4321-
count_partial(n, count_free);
4322-
4337+
if (flags & SO_TOTAL)
4338+
x = atomic_long_read(&n->total_objects);
4339+
else if (flags & SO_OBJECTS)
4340+
x = atomic_long_read(&n->total_objects) -
4341+
count_partial(n, count_free);
43234342
else
43244343
x = atomic_long_read(&n->nr_slabs);
43254344
total += x;
@@ -5135,7 +5154,8 @@ static char *create_unique_id(struct kmem_cache *s)
51355154

51365155
#ifdef CONFIG_MEMCG_KMEM
51375156
if (!is_root_cache(s))
5138-
p += sprintf(p, "-%08d", memcg_cache_id(s->memcg_params->memcg));
5157+
p += sprintf(p, "-%08d",
5158+
memcg_cache_id(s->memcg_params->memcg));
51395159
#endif
51405160

51415161
BUG_ON(p > name + ID_STR_LENGTH - 1);

0 commit comments

Comments
 (0)