From patchwork Fri Feb 28 12:13:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13996326 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A46326A1AC; Fri, 28 Feb 2025 12:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740744843; cv=none; b=sBZRL/fvZG+lf93z19dAZaLk1iacYlnYLs9bBTOL02TBowPFsOax3LxoJKq8fJ2JVuJP1fHx0JWOZ2eyw9xhtlQK2qbYBJLUsJPLZiiIoKNG1T5+mnkUNu7As4JqNrYgsqdeWIrqUlbi88LcETRKJ1olIOzn+gJyt3nDnM5Wubk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740744843; c=relaxed/simple; bh=tnfpMuVm4VBQfp3yu7qk3PMClI30zaEI7FgcpejGHl0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=nJZ3we27a8HZmODx8uzGgXVTPiu/pE6z/trBLHtkGXsE99gMz4LKoTMSUyl0aL5Hc0hgvnzJnM8NDf9WD0I/sMBPXnsRri429iQHfskEruy6PoKbW2SDAHwtTUhaRRlaxBkviktuWrRhP5//brwmWtX34mPXxXd5wANlHGHcca8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QMd+9NV4; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QMd+9NV4" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-548409cd2a8so2084383e87.3; Fri, 28 Feb 2025 04:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740744839; x=1741349639; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pkAygyolNUDpTR2GUn/c3jGDRfvql77S9asYrw4dJlg=; b=QMd+9NV4zsHqGHL5LRd8KJZSEJgfNUm61jvgygievHKi362sr1maqrSjLAD7tcj7m4 cVy78bEBHcAnuHp8KigNLg0BoY4jWwpYFC6lB+QfocQtu4ll/bWRm0ygjoRLGcRb6CM5 3+ZQVSrv4S4WGzDT52VlCdVjglurvytVKkJx5jzgLpfvWD+YrBEej9IwcTTHhz9dQAbC FEHYtigvXubjPl0O4eczBUIbJkT6immXod3mHnxNtYE+1BZNn0IE5aV2fcjErPSCDtbA 4iak+uRwMOUwnQRcd6eFStbofaAwxmGiQIXM3Lb0lh1Ei+AI08buw2kSvbYc7H83kgtc d0oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740744839; x=1741349639; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pkAygyolNUDpTR2GUn/c3jGDRfvql77S9asYrw4dJlg=; b=D26PFPi27Eiaf4XWqga5aH5fpfbDYDaw2ZMbgNAtl+EHwx2q2F1oHl6+8DkxVRFk4N izsmqY5/mF1v0lYLUlJQ3nCPdmuhU2NuTNj4IfbVjZxpr3dNZhM3lWpxa3NXGRi8MLuY xRvCOme64sfkVImevZ9MA0aJkkQ76HRMuceMgOgCkvUEDIDBCAhVkRcaRBNP2SSbSgIv cFVTQZCrNEnB6RHEWofKsowS2YqUxEoC2J9QR+/cQABqr68AFHAKikTFTSSq6fwBrGtA RlmXfv/VZtUME5SBQKvEIQxgYKyRTlfqI6LMq+lCe0iL6HX6ixCXbLlv/ZUtTckttCdE 7n3Q== X-Forwarded-Encrypted: i=1; AJvYcCUASeW4yxlRHL9WdfoKbzn9nNSU6a3/M4uA0xw3eGTxLZdHPf0BQVxn0inDSmr5hX8QcXujtV2XPoljx2I=@vger.kernel.org X-Gm-Message-State: AOJu0YxkR4F4mDCgsS3AlEGPxvO6rYw9fW9DVd67/wDtj/Vhi0yDfaDO VDpca+FqgH8XLrpZipxxv+BBe3IUX7nK9bXsAA9qWYw+s/UjFxl/ X-Gm-Gg: ASbGnct+pPL9wl3rc0kqrunEaj21wAlBhCpyXOP2G5yTnML/TLxnw6Nx9mcfr36Rvak cNOQQGlBoc8SMzDxUg+089VbqLN+YZ/8J/bn7hpvZskjWNGnedTtIYHXK1vEkih8Xupnc9FisYF opl3Alh1tnTteR603Jh13z0Z9Q0XfKIrP6JYnEtdcWjT9qQk7uczwVkXQYK/6tMDXJ5CFGOpw8Y TvCXF4o+COAVNXvbZLaR9dP3X0yBIU1k8XsoVehNdltpYbLP7VjlVG9Q8QufyBs2Qe4/RXm8Mx/ yWZ6BJ3VvryOstcShODJqg== X-Google-Smtp-Source: AGHT+IEE5Sgq0pD0++96L3Rw5rUNxBxVx36PbQHqHNZ8eGIdUS/xL5nATldx2m3megBQRV1h9xxkCw== X-Received: by 2002:a05:6512:3b11:b0:549:3be2:bfa3 with SMTP id 2adb3069b0e04-5494c320bfcmr1209187e87.30.1740744838853; Fri, 28 Feb 2025 04:13:58 -0800 (PST) Received: from pc638.lan ([2001:9b1:d5a0:a500:2d8:61ff:fec9:d743]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-549443ccfb7sm466768e87.230.2025.02.28.04.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2025 04:13:58 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: linux-mm@kvack.org, Andrew Morton , Vlastimil Babka Cc: RCU , LKML , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Uladzislau Rezki , Oleksiy Avramchenko , Keith Busch Subject: [PATCH v1 1/2] kunit, slub: Add test_kfree_rcu_wq_destroy use case Date: Fri, 28 Feb 2025 13:13:55 +0100 Message-Id: <20250228121356.336871-1-urezki@gmail.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a test_kfree_rcu_wq_destroy test to verify a kmem_cache_destroy() from a workqueue context. The problem is that, before destroying any cache the kvfree_rcu_barrier() is invoked to guarantee that in-flight freed objects are flushed. The _barrier() function queues and flushes its own internal workers which might conflict with a workqueue type a kmem-cache gets destroyed from. One example is when a WQ_MEM_RECLAIM workqueue is flushing !WQ_MEM_RECLAIM events which leads to a kernel splat. See the check_flush_dependency() in the workqueue.c file. If this test does not emits any kernel warning, it is passed. Reviewed-by: Keith Busch Co-developed-by: Vlastimil Babka Signed-off-by: Uladzislau Rezki (Sony) --- lib/slub_kunit.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index f11691315c2f..d47c472b0520 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "../mm/slab.h" static struct kunit_resource resource; @@ -181,6 +182,63 @@ static void test_kfree_rcu(struct kunit *test) KUNIT_EXPECT_EQ(test, 0, slab_errors); } +struct cache_destroy_work { + struct work_struct work; + struct kmem_cache *s; +}; + +static void cache_destroy_workfn(struct work_struct *w) +{ + struct cache_destroy_work *cdw; + + cdw = container_of(w, struct cache_destroy_work, work); + kmem_cache_destroy(cdw->s); +} + +#define KMEM_CACHE_DESTROY_NR 10 + +static void test_kfree_rcu_wq_destroy(struct kunit *test) +{ + struct test_kfree_rcu_struct *p; + struct cache_destroy_work cdw; + struct workqueue_struct *wq; + struct kmem_cache *s; + unsigned int delay; + int i; + + if (IS_BUILTIN(CONFIG_SLUB_KUNIT_TEST)) + kunit_skip(test, "can't do kfree_rcu() when test is built-in"); + + INIT_WORK_ONSTACK(&cdw.work, cache_destroy_workfn); + wq = alloc_workqueue("test_kfree_rcu_destroy_wq", + WQ_HIGHPRI | WQ_UNBOUND | WQ_MEM_RECLAIM, 0); + + if (!wq) + kunit_skip(test, "failed to alloc wq"); + + for (i = 0; i < KMEM_CACHE_DESTROY_NR; i++) { + s = test_kmem_cache_create("TestSlub_kfree_rcu_wq_destroy", + sizeof(struct test_kfree_rcu_struct), + SLAB_NO_MERGE); + + if (!s) + kunit_skip(test, "failed to create cache"); + + delay = get_random_u8(); + p = kmem_cache_alloc(s, GFP_KERNEL); + kfree_rcu(p, rcu); + + cdw.s = s; + + msleep(delay); + queue_work(wq, &cdw.work); + flush_work(&cdw.work); + } + + destroy_workqueue(wq); + KUNIT_EXPECT_EQ(test, 0, slab_errors); +} + static void test_leak_destroy(struct kunit *test) { struct kmem_cache *s = test_kmem_cache_create("TestSlub_leak_destroy", @@ -254,6 +312,7 @@ static struct kunit_case test_cases[] = { KUNIT_CASE(test_clobber_redzone_free), KUNIT_CASE(test_kmalloc_redzone_access), KUNIT_CASE(test_kfree_rcu), + KUNIT_CASE(test_kfree_rcu_wq_destroy), KUNIT_CASE(test_leak_destroy), KUNIT_CASE(test_krealloc_redzone_zeroing), {} From patchwork Fri Feb 28 12:13:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13996327 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9CC2512E4; Fri, 28 Feb 2025 12:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740744845; cv=none; b=tX7aetiEBVWZuQImFLTHmVccoUFITG55spGirp+51rfG8Y1Tj2kiDMpnEoEqoHFVH7e5X53z0szkOFOsKr38vONH0+/dzlLe8jSpYeqsdY3n9MCeTJqCds4kn2UKCsR/y76Gr9speH8ER3UyMRkYvMDCrRw6WLAr6Q4ko56eDoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740744845; c=relaxed/simple; bh=sPI0/4VZGmNNeeEBTgM25yhUxGKq5I/M70bt5OBJzNc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A4fPA1eZOwDna6XTzkysZk1eFbG8P2Z9BXY5UmwDyNWZW7yhthbcbByv1L74F+ldBAUKVEWwOMD+1aF6FFxjHi/+z+S3MTNfoSVEjS1lZgGeQbLW/0PUp7cgMCoMVk+P6vwo6m0ltrEyuOG4L/uZ265Xml5MudwCbNayk7NRqgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=e5j0GbqO; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e5j0GbqO" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-54843052bcdso1832338e87.1; Fri, 28 Feb 2025 04:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740744840; x=1741349640; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OmfLoEbURepgZnFJrXzUMOPeijT6w0Yd6T6cBLnYL24=; b=e5j0GbqOBoNxm871MjDC5g277t8zTyuYzfKrJ5LbH3Ni45d2T8lhxwsxgLsfGoVQvw wBXlLhxWeYp0STxpAHrkbSsMiC5ZgWlvL1KbqrRJmfkrauJfitaiLq6ZhIkyrVmUCcE0 5fIROe3RG372WjRsnfJs1SoTgbK86HJ+0+kzw8c5CAKSx3+ijh1iM2wfKjlQJoc1yML9 Go0h39yjWiSRHWWod2KEi2ejsobUUw+obuTkKwNVtORDz32ayB8cmUQYKnGh0mstCWBh 15C5HL1ycwaS86FQRB6uUqNHMendjDAWZNNn0ya6Wd4Nij+ei4NLXfiXV7mvtaWDUf5w U5Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740744840; x=1741349640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OmfLoEbURepgZnFJrXzUMOPeijT6w0Yd6T6cBLnYL24=; b=DeiEeVjRcyDVyKSQIrXPPJb6GMFQEHP3WU5fdRH2iWrDIFz49qBu4k02Z12qsiqN6b lCcrqb6gWTsyEuHtkAYWNrI5JhZY4iYEHMM4dVLYk86DJIVbEXNhZ6TaGinDzbFfS/7S DPG6eJ2ooTk8QECm6vV/JG1AnsOpJ6hHiXLdWhFyMVikwZXxhYUuAmtl7qowvHJ1d+4n YJV40xNeeSVPqVhwga4/UJYcENqWXhbzqtdeaP1zc+5k2VdTcB4Fhft3XJXeQvuqVr09 D1TMxjjMLMtzqAp3RhdvhNWd+xBPVhokcvj3A569WaXq5jeKxZKDBZDvpThtREWvgFba dzrg== X-Forwarded-Encrypted: i=1; AJvYcCUCFdKbgGlnpeu02o6UEZlN/5jFvzsGtp8ZM6bbw9r+M/jze+cMEfhEsXvlwlgwYKsufgtX3buFVD/pjLo=@vger.kernel.org, AJvYcCVHo1BHBVacwwGcs9Hk95iJGHoRQYfwHm+3y9BQCccqgs/TMU2zmPuz/8MAmZXt+k4U8YSep+xS@vger.kernel.org X-Gm-Message-State: AOJu0Yx2cFM38lHcLAW+ytvYdy2NOnxMBPvPHPFqZ9S8k3wxs4hOSdvv 71MprPDS8mYe/JdWzGEQqZlIPXIlzW3OVVKO4lwRUhhvph8uh+5Q X-Gm-Gg: ASbGncsWcyA5lL2mjbLIm8kPMnTnfMQ2WX1afP0bKxAVjfFW/ihdq0mADxTlDiu7cCj jP55nLabap+qfXAthmkDMH3XyG5hpz+VyUGz/9wa24RryMbF3ogocBbB5kmEdhWRSlbSnnWM3s+ k3n+18nKfP4T1tP+VGAS5h3Lk/C7K8Mk7zK9F96sh32a5wUUwYKMPl4Dbaw2izMvTXdQgH1H+dA qZ3ApD5h7s7T1sLaBFgsV5DzGZoyfcCLs4mMOe7xGSE4aDLhTgGdByETLMmmTFuRKvAVJ2uiN8s hy1Tp62JiJahxJnzn1D+mw== X-Google-Smtp-Source: AGHT+IEXGMGMYueYdcrpqWDZP3Db10Z+3IUdwOgX1zq1vhWUt4E/pPLBdUzUf2huoovEztV/l2vIig== X-Received: by 2002:a05:6512:1108:b0:549:3adf:89d8 with SMTP id 2adb3069b0e04-5494c368cb8mr1014440e87.53.1740744839988; Fri, 28 Feb 2025 04:13:59 -0800 (PST) Received: from pc638.lan ([2001:9b1:d5a0:a500:2d8:61ff:fec9:d743]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-549443ccfb7sm466768e87.230.2025.02.28.04.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2025 04:13:59 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: linux-mm@kvack.org, Andrew Morton , Vlastimil Babka Cc: RCU , LKML , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Uladzislau Rezki , Oleksiy Avramchenko , stable@vger.kernel.org, Greg Kroah-Hartman , Keith Busch Subject: [PATCH v1 2/2] mm/slab/kvfree_rcu: Switch to WQ_MEM_RECLAIM wq Date: Fri, 28 Feb 2025 13:13:56 +0100 Message-Id: <20250228121356.336871-2-urezki@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250228121356.336871-1-urezki@gmail.com> References: <20250228121356.336871-1-urezki@gmail.com> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently kvfree_rcu() APIs use a system workqueue which is "system_unbound_wq" to driver RCU machinery to reclaim a memory. Recently, it has been noted that the following kernel warning can be observed: workqueue: WQ_MEM_RECLAIM nvme-wq:nvme_scan_work is flushing !WQ_MEM_RECLAIM events_unbound:kfree_rcu_work WARNING: CPU: 21 PID: 330 at kernel/workqueue.c:3719 check_flush_dependency+0x112/0x120 Modules linked in: intel_uncore_frequency(E) intel_uncore_frequency_common(E) skx_edac(E) ... CPU: 21 UID: 0 PID: 330 Comm: kworker/u144:6 Tainted: G E 6.13.2-0_g925d379822da #1 Hardware name: Wiwynn Twin Lakes MP/Twin Lakes Passive MP, BIOS YMM20 02/01/2023 Workqueue: nvme-wq nvme_scan_work RIP: 0010:check_flush_dependency+0x112/0x120 Code: 05 9a 40 14 02 01 48 81 c6 c0 00 00 00 48 8b 50 18 48 81 c7 c0 00 00 00 48 89 f9 48 ... RSP: 0018:ffffc90000df7bd8 EFLAGS: 00010082 RAX: 000000000000006a RBX: ffffffff81622390 RCX: 0000000000000027 RDX: 00000000fffeffff RSI: 000000000057ffa8 RDI: ffff88907f960c88 RBP: 0000000000000000 R08: ffffffff83068e50 R09: 000000000002fffd R10: 0000000000000004 R11: 0000000000000000 R12: ffff8881001a4400 R13: 0000000000000000 R14: ffff88907f420fb8 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88907f940000(0000) knlGS:0000000000000000 CR2: 00007f60c3001000 CR3: 000000107d010005 CR4: 00000000007726f0 PKRU: 55555554 Call Trace: ? __warn+0xa4/0x140 ? check_flush_dependency+0x112/0x120 ? report_bug+0xe1/0x140 ? check_flush_dependency+0x112/0x120 ? handle_bug+0x5e/0x90 ? exc_invalid_op+0x16/0x40 ? asm_exc_invalid_op+0x16/0x20 ? timer_recalc_next_expiry+0x190/0x190 ? check_flush_dependency+0x112/0x120 ? check_flush_dependency+0x112/0x120 __flush_work.llvm.1643880146586177030+0x174/0x2c0 flush_rcu_work+0x28/0x30 kvfree_rcu_barrier+0x12f/0x160 kmem_cache_destroy+0x18/0x120 bioset_exit+0x10c/0x150 disk_release.llvm.6740012984264378178+0x61/0xd0 device_release+0x4f/0x90 kobject_put+0x95/0x180 nvme_put_ns+0x23/0xc0 nvme_remove_invalid_namespaces+0xb3/0xd0 nvme_scan_work+0x342/0x490 process_scheduled_works+0x1a2/0x370 worker_thread+0x2ff/0x390 ? pwq_release_workfn+0x1e0/0x1e0 kthread+0xb1/0xe0 ? __kthread_parkme+0x70/0x70 ret_from_fork+0x30/0x40 ? __kthread_parkme+0x70/0x70 ret_from_fork_asm+0x11/0x20 ---[ end trace 0000000000000000 ]--- To address this switch to use of independent WQ_MEM_RECLAIM workqueue, so the rules are not violated from workqueue framework point of view. Apart of that, since kvfree_rcu() does reclaim memory it is worth to go with WQ_MEM_RECLAIM type of wq because it is designed for this purpose. Cc: Cc: Greg Kroah-Hartman Cc: Keith Busch Closes: https://www.spinics.net/lists/kernel/msg5563270.html Fixes: 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"), Reported-by: Keith Busch Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Joel Fernandes --- mm/slab_common.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 4030907b6b7d..4c9f0a87f733 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1304,6 +1304,8 @@ module_param(rcu_min_cached_objs, int, 0444); static int rcu_delay_page_cache_fill_msec = 5000; module_param(rcu_delay_page_cache_fill_msec, int, 0444); +static struct workqueue_struct *rcu_reclaim_wq; + /* Maximum number of jiffies to wait before draining a batch. */ #define KFREE_DRAIN_JIFFIES (5 * HZ) #define KFREE_N_BATCHES 2 @@ -1632,10 +1634,10 @@ __schedule_delayed_monitor_work(struct kfree_rcu_cpu *krcp) if (delayed_work_pending(&krcp->monitor_work)) { delay_left = krcp->monitor_work.timer.expires - jiffies; if (delay < delay_left) - mod_delayed_work(system_unbound_wq, &krcp->monitor_work, delay); + mod_delayed_work(rcu_reclaim_wq, &krcp->monitor_work, delay); return; } - queue_delayed_work(system_unbound_wq, &krcp->monitor_work, delay); + queue_delayed_work(rcu_reclaim_wq, &krcp->monitor_work, delay); } static void @@ -1733,7 +1735,7 @@ kvfree_rcu_queue_batch(struct kfree_rcu_cpu *krcp) // "free channels", the batch can handle. Break // the loop since it is done with this CPU thus // queuing an RCU work is _always_ success here. - queued = queue_rcu_work(system_unbound_wq, &krwp->rcu_work); + queued = queue_rcu_work(rcu_reclaim_wq, &krwp->rcu_work); WARN_ON_ONCE(!queued); break; } @@ -1883,7 +1885,7 @@ run_page_cache_worker(struct kfree_rcu_cpu *krcp) if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING && !atomic_xchg(&krcp->work_in_progress, 1)) { if (atomic_read(&krcp->backoff_page_cache_fill)) { - queue_delayed_work(system_unbound_wq, + queue_delayed_work(rcu_reclaim_wq, &krcp->page_cache_work, msecs_to_jiffies(rcu_delay_page_cache_fill_msec)); } else { @@ -2120,6 +2122,10 @@ void __init kvfree_rcu_init(void) int i, j; struct shrinker *kfree_rcu_shrinker; + rcu_reclaim_wq = alloc_workqueue("kvfree_rcu_reclaim", + WQ_UNBOUND | WQ_MEM_RECLAIM, 0); + WARN_ON(!rcu_reclaim_wq); + /* Clamp it to [0:100] seconds interval. */ if (rcu_delay_page_cache_fill_msec < 0 || rcu_delay_page_cache_fill_msec > 100 * MSEC_PER_SEC) {