Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'slab/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux

* 'slab/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux:
slub: avoid potential NULL dereference or corruption
slub: use irqsafe_cpu_cmpxchg for put_cpu_partial
slub: move discard_slab out of node lock
slub: use correct parameter to add a page to partial list tail

+26 -16
+26 -16
mm/slub.c
··· 1862 1862 { 1863 1863 struct kmem_cache_node *n = NULL; 1864 1864 struct kmem_cache_cpu *c = this_cpu_ptr(s->cpu_slab); 1865 - struct page *page; 1865 + struct page *page, *discard_page = NULL; 1866 1866 1867 1867 while ((page = c->partial)) { 1868 1868 enum slab_modes { M_PARTIAL, M_FREE }; ··· 1904 1904 if (l == M_PARTIAL) 1905 1905 remove_partial(n, page); 1906 1906 else 1907 - add_partial(n, page, 1); 1907 + add_partial(n, page, 1908 + DEACTIVATE_TO_TAIL); 1908 1909 1909 1910 l = m; 1910 1911 } ··· 1916 1915 "unfreezing slab")); 1917 1916 1918 1917 if (m == M_FREE) { 1919 - stat(s, DEACTIVATE_EMPTY); 1920 - discard_slab(s, page); 1921 - stat(s, FREE_SLAB); 1918 + page->next = discard_page; 1919 + discard_page = page; 1922 1920 } 1923 1921 } 1924 1922 1925 1923 if (n) 1926 1924 spin_unlock(&n->list_lock); 1925 + 1926 + while (discard_page) { 1927 + page = discard_page; 1928 + discard_page = discard_page->next; 1929 + 1930 + stat(s, DEACTIVATE_EMPTY); 1931 + discard_slab(s, page); 1932 + stat(s, FREE_SLAB); 1933 + } 1927 1934 } 1928 1935 1929 1936 /* ··· 1978 1969 page->pobjects = pobjects; 1979 1970 page->next = oldpage; 1980 1971 1981 - } while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page) != oldpage); 1972 + } while (irqsafe_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page) != oldpage); 1982 1973 stat(s, CPU_PARTIAL_FREE); 1983 1974 return pobjects; 1984 1975 } ··· 4444 4435 4445 4436 for_each_possible_cpu(cpu) { 4446 4437 struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu); 4438 + int node = ACCESS_ONCE(c->node); 4447 4439 struct page *page; 4448 4440 4449 - if (!c || c->node < 0) 4441 + if (node < 0) 4450 4442 continue; 4451 - 4452 - if (c->page) { 4453 - if (flags & SO_TOTAL) 4454 - x = c->page->objects; 4443 + page = ACCESS_ONCE(c->page); 4444 + if (page) { 4445 + if (flags & SO_TOTAL) 4446 + x = page->objects; 4455 4447 else if (flags & SO_OBJECTS) 4456 - x = c->page->inuse; 4448 + x = page->inuse; 4457 4449 else 4458 4450 x = 1; 4459 4451 4460 4452 total += x; 4461 - nodes[c->node] += x; 4453 + nodes[node] += x; 4462 4454 } 4463 4455 page = c->partial; 4464 4456 4465 4457 if (page) { 4466 4458 x = page->pobjects; 4467 - total += x; 4468 - nodes[c->node] += x; 4459 + total += x; 4460 + nodes[node] += x; 4469 4461 } 4470 - per_cpu[c->node]++; 4462 + per_cpu[node]++; 4471 4463 } 4472 4464 } 4473 4465