Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4819889ybl; Wed, 22 Jan 2020 05:22:17 -0800 (PST) X-Google-Smtp-Source: APXvYqxPOq0ftl93BnWEswo8PCoASK/2/pgdo9qig6I+ElVWrq7GwLWRWI1jJCM+IA5yDbEWQZkn X-Received: by 2002:a9d:774e:: with SMTP id t14mr7178206otl.358.1579699337117; Wed, 22 Jan 2020 05:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699337; cv=none; d=google.com; s=arc-20160816; b=t0Vi3E83pbcSjbUAOduhITBcvDQL26daBOI8eChDPFvPn/IBtso8GdlUDWJGkHa2QI FGPF4BbEpU1aZQHtZAwyKM5gAunO9tvkptpNGnOOcOEJ2kBQ9dwDwPC4+x8/dYD/B8Z5 DgSA0IlpQ/yByF1MuMyB2To1kdhmbACrTY2X/ZlQD6OFgC1QI2CXS6ZcsGRXMa7cBRbA C0JKNElhfqfa1D6xyP59lU/HvURkG5iP2bIBNto/aWKVcC4lAOVq0EBwn9hQGivrIpvt Lki1BbdMyi8idIu9epai3YCmTnZEGMAmns1kvZZB0WEEDCSQOuYdDGxtMQeHq/9qtIVt BjNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LjCt1x+RjyFqFK2UKv6RFsp0hAaB+wcN5/afmWyeflQ=; b=q+ttT9EbFWLRbL+NfpHIf8AqXqO/vROvGVN4Uc+ZYIMTp7G7uejsA02pwH5M/sVfmZ LA61a7on5HPjmmKNbrgAGmXdnolVBsQRVKPDOMvCnbfiBEN7XORT4OIx4xcFl0/brN3Q L8Ot+yGwsASPC5cjdf3zkygXWMeIpa4YP4XGYR+NfKTqO6WDPGek37nXikW26oa0otHs 5dowQPRwfAdPKaI7AUmgyUBkiJWY83ATRMvrN5pRu/PyScnw38fxwE6SQinQ+Ljtvfq/ XQ3nVMrpWj2TPTWeYkqJ1QcsBk8iMQETs8XC7m59Z8w+E1ekeB1cJyBfYqbT1qntnEzv 7sFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v1CMuedg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si25623340otk.221.2020.01.22.05.22.05; Wed, 22 Jan 2020 05:22:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v1CMuedg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729991AbgAVNUd (ORCPT + 99 others); Wed, 22 Jan 2020 08:20:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:36778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729368AbgAVNUa (ORCPT ); Wed, 22 Jan 2020 08:20:30 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E9EDC24125; Wed, 22 Jan 2020 13:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699229; bh=xhmPu01T1Q+loCI8xtjqHscvjwS+eSfiTFSimH8jT/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v1CMuedgLCRAPCeS2YU1UUIwX5zYrZrE9qDDjHvdzrmEjS8sh6abnx2Bv+/Nrk/0N FUSJCSlvlWM1bDY9lmSjAff9kSyTTYYEEB/oSF4cXRYUQlQE8hPoF8Ie8UxlEiV2Xg I3N/M3JXcARgc73p4gyqZKcZmC0iEuujt3g+R0aE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Huang , Xiaochun Lee , Shakeel Butt , Joerg Roedel , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Michal Hocko , Johannes Weiner , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 081/222] mm: memcg/slab: call flush_memcg_workqueue() only if memcg workqueue is valid Date: Wed, 22 Jan 2020 10:27:47 +0100 Message-Id: <20200122092839.510902160@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Huang commit 2fe20210fc5f5e62644678b8f927c49f2c6f42a7 upstream. 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 Call Trace: 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(). Link: http://lkml.kernel.org/r/20200103085503.1665-1-ahuang12@lenovo.com Fixes: 92ee383f6daab ("mm: fix race between kmem_cache destroy, create and deactivate") Signed-off-by: Adrian Huang Reported-by: Xiaochun Lee Reviewed-by: Shakeel Butt Cc: Joerg Roedel Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Michal Hocko Cc: Johannes Weiner Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/slab_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -903,7 +903,8 @@ static void flush_memcg_workqueue(struct * 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