From patchwork Fri Jan 3 08:55:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Huang X-Patchwork-Id: 11316673 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 27F931398 for ; Fri, 3 Jan 2020 08:55:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DF72821734 for ; Fri, 3 Jan 2020 08:55:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q2039Hre" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF72821734 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2897F8E0011; Fri, 3 Jan 2020 03:55:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 239F68E0003; Fri, 3 Jan 2020 03:55:49 -0500 (EST) 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 1509A8E0011; Fri, 3 Jan 2020 03:55:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 001DC8E0003 for ; Fri, 3 Jan 2020 03:55:48 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 93027181AC9CB for ; Fri, 3 Jan 2020 08:55:48 +0000 (UTC) X-FDA: 76335715176.01.duck82_6cdffb89c2c26 X-Spam-Summary: 2,0,0,4a193ad02bd48af4,d41d8cd98f00b204,adrianhuang0701@gmail.com,:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com:akpm@linux-foundation.org::ahuang12@lenovo.com:shakeelb@google.com:jroedel@suse.de,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1431:1437:1535:1543:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3354:3865:3866:3867:3870:3871:3872:3874:4117:4250:4321:4385:4605:5007:6238:6261:6653:7576:7903:7974:8660:8957:9121:9163:9413:9707:10004:10241:11026:11658:11914:12043:12048:12114:12296:12297:12438:12517:12519:12555:12679:12740:12895:12986:13095:13148:13161:13221:13229:13230:13255:13870:14096:14181:14394:14687:14721:14799:21063:21080:21212:21324:21433:21444:21451:21622:21666:21740:21966:30012:30029:30054:30056,0,RBL:209.85.210.194:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DN SBL:neut X-HE-Tag: duck82_6cdffb89c2c26 X-Filterd-Recvd-Size: 6207 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Jan 2020 08:55:48 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id z16so23281452pfk.0 for ; Fri, 03 Jan 2020 00:55:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xdMQ777zuU2bmKm5Bo6t8ZpOfaCkuaGTOOJGmPuF+hk=; b=q2039HreJzO+LilHRnxgUrxB3ZzB9GZ3fOmTfMfCc0wTQ56Gu7a3ivjLCyHtw3ZK64 Bk6vLjxPGxtw/SFHA6chGw7rTO1ENW8xWetjh3CqLtJfVIwv5RIULdmtdjxjY86KzY73 gvJ8rqW/YBXqnNxdKtipffsaAGu55i56gz9d5hF1rzjdwPOe6C8XI11g4xJxLmcg3z2S g5RfziU4sOMy1ZrCeyTnmdfsm2FPqGFo3lgYCV0fVwn/K3KUj1CiUG9QrLHWkf0AIgpI QEVIF5zpP21IsNDdYuzo7KIVs+X9QGCiUKG0UrZWL5VaVbYITt911i3fW3JlMNhD/xru 3n/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xdMQ777zuU2bmKm5Bo6t8ZpOfaCkuaGTOOJGmPuF+hk=; b=pBdF3YXtEXB+Pjch84mgsYeMZmWhgY4kxqNHsMxboAQ6xShqR4vpmEzcYHzW9gh+TK ciSAbhtJze8jar9zYRIWXxXXgrlfZ5NpEnsKGZWGGxj7IKYs+EyJyLk7xULcYPRmq8E5 sKUlttsx6lrQFZGnawfZrsJOLqrXJzj5Z8j966iwVhXncPTOGzWUyLYHDLP6oPCc+3yQ tGDU3rK+GcOwrtneC1FvxIeReqBIuKN9yeAADeVSpjD3P+AHnP6go1cs4u4st/lhO5AN YXJ/SJRRD9oK1bhekYjxw/S84/MJtmrQudIbELfXxxiu0Nmk/cUN7N60OMRR+zYAHbfM F8Zw== X-Gm-Message-State: APjAAAVFIWuGiY7hX0GrUr1QVMwBTBbopeJ7am4OizdjsafY09PSt7oP RZRhB7z41fE0oC5J26CuqO4= X-Google-Smtp-Source: APXvYqwICKurreBLg09f5eNVwQ1fAp1owonA+QE7J8gzn1l+MHhLHrD9X9woFrWHtn4lherirPGNxg== X-Received: by 2002:a62:8247:: with SMTP id w68mr86005892pfd.2.1578041746953; Fri, 03 Jan 2020 00:55:46 -0800 (PST) Received: from AHUANG12-1LT7M0.lenovo.com (36-237-123-104.dynamic-ip.hinet.net. [36.237.123.104]) by smtp.googlemail.com with ESMTPSA id u2sm61913796pgc.19.2020.01.03.00.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 00:55:46 -0800 (PST) From: Adrian Huang X-Google-Original-From: Adrian Huang To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton Cc: linux-mm@kvack.org, Adrian Huang , Shakeel Butt , Joerg Roedel Subject: [PATCH 1/1] mm: memcg/slab: Call flush_memcg_workqueue() only if memcg workqueue is valid Date: Fri, 3 Jan 2020 16:55:03 +0800 Message-Id: <20200103085503.1665-1-ahuang12@lenovo.com> X-Mailer: git-send-email 2.17.1 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: From: Adrian Huang When booting with amd_iommu=off, the following WARNING message appears: AMD-Vi: AMD IOMMU disabled on kernel command-line ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at kernel/workqueue.c:2772 flush_workqueue+0x42e/0x450 Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.5.0-rc3-amd-iommu #6 Hardware name: Lenovo ThinkSystem SR655-2S/7D2WRCZ000, BIOS D8E101L-1.00 12/05/2019 RIP: 0010:flush_workqueue+0x42e/0x450 Code: ff 0f 0b e9 7a fd ff ff 4d 89 ef e9 33 fe ff ff 0f 0b e9 7f fd ff ff 0f 0b e9 bc fd ff ff 0f 0b e9 a8 fd ff ff e8 52 2c fe ff <0f> 0b 31 d2 48 c7 c6 e0 88 c5 95 48 c7 c7 d8 ad f0 95 e8 19 f5 04 RSP: 0000:ffffffff96203d80 EFLAGS: 00010246 RAX: ffffffff96203dc8 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffffffff96a63120 RSI: ffffffff95efcba2 RDI: ffffffff96203dc0 RBP: ffffffff96203e08 R08: 0000000000000000 R09: ffffffff962a1828 R10: 00000000f0000080 R11: dead000000000100 R12: ffff8d8a87c0a770 R13: dead000000000100 R14: 0000000000000456 R15: ffffffff96203da0 FS: 0000000000000000(0000) GS:ffff8d8dbd000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffff8d91cfbff000 CR3: 000000078920a000 CR4: 00000000000406b0 Call Trace: ? wait_for_completion+0x51/0x180 kmem_cache_destroy+0x69/0x260 iommu_go_to_state+0x40c/0x5ab amd_iommu_prepare+0x16/0x2a irq_remapping_prepare+0x36/0x5f enable_IR_x2apic+0x21/0x172 default_setup_apic_routing+0x12/0x6f apic_intr_mode_init+0x1a1/0x1f1 x86_late_time_init+0x17/0x1c start_kernel+0x480/0x53f secondary_startup_64+0xb6/0xc0 ---[ end trace 30894107c3749449 ]--- x2apic: IRQ remapping doesn't support X2APIC mode x2apic disabled The warning is caused by the calling of 'kmem_cache_destroy()' in free_iommu_resources(). Here is the call path: free_iommu_resources kmem_cache_destroy flush_memcg_workqueue flush_workqueue The root cause is that the IOMMU subsystem runs before the workqueue subsystem, which the variable 'wq_online' is still 'false'. This leads to the statement 'if (WARN_ON(!wq_online))' in flush_workqueue() is 'true'. Since the variable 'memcg_kmem_cache_wq' is not allocated during the time, it is unnecessary to call flush_memcg_workqueue(). This prevents the WARNING message triggered by flush_workqueue(). Cc: Shakeel Butt Cc: Joerg Roedel Reported-by: Xiaochun Lee Signed-off-by: Adrian Huang Reviewed-by: Shakeel Butt --- mm/slab_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index f0ab6d4ceb4c..0d95ddea13b0 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -903,7 +903,8 @@ static void flush_memcg_workqueue(struct kmem_cache *s) * deactivates the memcg kmem_caches through workqueue. Make sure all * previous workitems on workqueue are processed. */ - flush_workqueue(memcg_kmem_cache_wq); + if (likely(memcg_kmem_cache_wq)) + flush_workqueue(memcg_kmem_cache_wq); /* * If we're racing with children kmem_cache deactivation, it might