From patchwork Thu Jun 18 20:12:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 11612953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 410E5913 for ; Thu, 18 Jun 2020 20:12:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E79B207E8 for ; Thu, 18 Jun 2020 20:12:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E79B207E8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2528D8D005B; Thu, 18 Jun 2020 16:12:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1DBCE8D0052; Thu, 18 Jun 2020 16:12:48 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CD018D005B; Thu, 18 Jun 2020 16:12:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id E540D8D0052 for ; Thu, 18 Jun 2020 16:12:47 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A00B082499B9 for ; Thu, 18 Jun 2020 20:12:47 +0000 (UTC) X-FDA: 76943430774.10.tree33_0803d8d26e13 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 7E0A62D71EC for ; Thu, 18 Jun 2020 20:12:47 +0000 (UTC) X-Spam-Summary: 2,0,0,3fb351132009a511,d41d8cd98f00b204,bigeasy@linutronix.de,,RULES_HIT:41:69:355:379:541:800:960:966:967:968:973:988:989:1260:1261:1311:1314:1345:1359:1437:1513:1515:1521:1534:1542:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2525:2559:2563:2682:2685:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4384:4385:4395:4605:5007:6261:9025:9592:10004:11026:11473:11658:11914:12043:12160:12296:12297:12438:12555:12679:12895:12986:13161:13172:13229:14096:14181:14394:14721:21080:21433:21451:21627:21939:21966:21990:30012:30029:30054:30070,0,RBL:193.142.43.55:@linutronix.de:.lbl8.mailshell.net-62.14.6.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: tree33_0803d8d26e13 X-Filterd-Recvd-Size: 3512 Received: from Galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 20:12:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=flow.W.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1jm0tv-00028j-9P; Thu, 18 Jun 2020 22:12:43 +0200 From: Sebastian Andrzej Siewior To: linux-mm@kvack.org Cc: Christopher Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 1/2] slub: Cure list_slab_objects() from double fix Date: Thu, 18 Jun 2020 22:12:33 +0200 Message-Id: <20200618201234.795692-1-bigeasy@linutronix.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 7E0A62D71EC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: According to Christopher Lameter two fixes have been merged for the same problem. As far as I can tell, the code does not acquire the list_lock and invoke kmalloc(). list_slab_objects() misses an unlock (the counterpart to get_map()) and the memory allocated in free_partial() isn't used. Revert the mentioned commit. Fixes: aa456c7aebb14 ("slub: remove kmalloc under list_lock from list_slab_objects() V2") Link: https://lkml.kernel.org/r/alpine.DEB.2.22.394.2006181501480.12014@www.lameter.com Signed-off-by: Sebastian Andrzej Siewior --- mm/slub.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index b8f798b50d44d..72195cafbb503 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3766,15 +3766,13 @@ static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags) } static void list_slab_objects(struct kmem_cache *s, struct page *page, - const char *text, unsigned long *map) + const char *text) { #ifdef CONFIG_SLUB_DEBUG void *addr = page_address(page); + unsigned long *map; void *p; - if (!map) - return; - slab_err(s, page, text, s->name); slab_lock(page); @@ -3786,6 +3784,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, print_tracking(s, p); } } + put_map(map); slab_unlock(page); #endif } @@ -3799,11 +3798,6 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) { LIST_HEAD(discard); struct page *page, *h; - unsigned long *map = NULL; - -#ifdef CONFIG_SLUB_DEBUG - map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL); -#endif BUG_ON(irqs_disabled()); spin_lock_irq(&n->list_lock); @@ -3813,16 +3807,11 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) list_add(&page->slab_list, &discard); } else { list_slab_objects(s, page, - "Objects remaining in %s on __kmem_cache_shutdown()", - map); + "Objects remaining in %s on __kmem_cache_shutdown()"); } } spin_unlock_irq(&n->list_lock); -#ifdef CONFIG_SLUB_DEBUG - bitmap_free(map); -#endif - list_for_each_entry_safe(page, h, &discard, slab_list) discard_slab(s, page); } From patchwork Thu Jun 18 20:12:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 11612955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C488B92A for ; Thu, 18 Jun 2020 20:12:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 918C8207E8 for ; Thu, 18 Jun 2020 20:12:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 918C8207E8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D4F008D005C; Thu, 18 Jun 2020 16:12:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD86E8D0052; Thu, 18 Jun 2020 16:12:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC8BF8D005C; Thu, 18 Jun 2020 16:12:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id A09D18D0052 for ; Thu, 18 Jun 2020 16:12:51 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 62EFA82499B9 for ; Thu, 18 Jun 2020 20:12:51 +0000 (UTC) X-FDA: 76943430942.01.trees10_470640926e13 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id EA15E20001BBAB2A for ; Thu, 18 Jun 2020 20:12:50 +0000 (UTC) X-Spam-Summary: 2,0,0,b903606b2c4e339d,d41d8cd98f00b204,bigeasy@linutronix.de,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1311:1314:1345:1359:1437:1513:1515:1521:1534:1540:1711:1714:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3351:3867:3868:3870:3871:3872:3874:4419:5007:6261:9592:10004:11026:11473:11658:11914:12043:12114:12160:12296:12297:12555:12895:13069:13161:13229:13311:13357:14096:14181:14384:14394:14721:21080:21451:21627:21740:21987:30054:30070,0,RBL:193.142.43.55:@linutronix.de:.lbl8.mailshell.net-64.201.201.201 62.8.6.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: trees10_470640926e13 X-Filterd-Recvd-Size: 2092 Received: from Galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 20:12:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=flow.W.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1jm0tw-00028j-6W; Thu, 18 Jun 2020 22:12:44 +0200 From: Sebastian Andrzej Siewior To: linux-mm@kvack.org Cc: Christopher Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Thomas Gleixner , Sebastian Andrzej Siewior , Yu Zhao Subject: [PATCH 2/2] slub: Drop lockdep_assert_held() from put_map() Date: Thu, 18 Jun 2020 22:12:34 +0200 Message-Id: <20200618201234.795692-2-bigeasy@linutronix.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200618201234.795692-1-bigeasy@linutronix.de> References: <20200618201234.795692-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: EA15E20001BBAB2A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: There is no point in using lockdep_assert_held() unlock that is about to be unlocked. It works only with lockdep and lockdep will complain if spin_unlock() is used on a lock that has not been locked. Remove superfluous lockdep_assert_held(). Cc: Yu Zhao Signed-off-by: Sebastian Andrzej Siewior --- mm/slub.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 72195cafbb503..5a43ad225427f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -469,8 +469,6 @@ static unsigned long *get_map(struct kmem_cache *s, struct page *page) static void put_map(unsigned long *map) __releases(&object_map_lock) { VM_BUG_ON(map != object_map); - lockdep_assert_held(&object_map_lock); - spin_unlock(&object_map_lock); }