Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp128279ybz; Tue, 28 Apr 2020 19:56:38 -0700 (PDT) X-Google-Smtp-Source: APiQypKxnbAuPc30PcHWa1lADtmhL9QIsqbBAenCkzdDNZyFUOHNeTYpcwyH5VKy1i1Fh0urN9FP X-Received: by 2002:a17:906:31d7:: with SMTP id f23mr681210ejf.118.1588128998046; Tue, 28 Apr 2020 19:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588128998; cv=none; d=google.com; s=arc-20160816; b=J5YzloCUmsxhpZgzgUgRzHF37R82IOziet0svDl6qLXKyiUmsPz7OPtvwdW5aMaYrX CIdE/0GkYa8LReJWOrmwrfYHbl3Y/p3ZiGYcH9QjkWMujjIRXs38JoB2unu/NteXMCkr Zcxb/4tejCTOMpnYA8I29GGjfUVNSq7o11aUtUZekCfXevXVMiqrCgQagUD+CGQ/l537 Pq3VR0gwE2MUU97x+Hd/s0zum6mIPwEEJKRTRTKnb3aSqaRcLAjFa0u3J6uGYXzyS058 SvDd62khVmlcHKEmxeX4neBREaXsqfVwhisMmO0sA9C44XQPqAdAnTLEXaSscxHJpg9C iKjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=ZuYhQOwVqj5I2l0C3mwcWWBRC4vXsL2shmKKYh/lrQg=; b=QDbwDlh8H3X2HJfLDH7WH7OSnodi68SrwxgczLpS2EyRS/V5CqOWw7EAxp+/V2Qzo1 kY7sHc8BovsaL1E/83smJZoh9ORN1tsAI9emYY88Mva/MrR9eUEb+EyiWQMCv6pi4mog 5PpS5TuZVbRcyjFp7czgtJjSxrk0U5Fnudd5hTAz7mRwdUDdxH4YW1xFnFQNnabQdBoS rl4lnpHKzXfCmc8DcLHCfv96LoCRieih+rRfuaVWi22fmK6PgefIloVWlkY6jijBIHFI cfKMO1EhTDqXy3xshPOB1ITJl5+Maa8sFPHeT7jWzQLPbnGnpBg7BpzWaB7M96V4lTPM YRGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=aCmH7Cwl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi13si2858972edb.449.2020.04.28.19.56.13; Tue, 28 Apr 2020 19:56:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=aCmH7Cwl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbgD2Cww (ORCPT + 99 others); Tue, 28 Apr 2020 22:52:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726498AbgD2Cww (ORCPT ); Tue, 28 Apr 2020 22:52:52 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F046FC03C1AC for ; Tue, 28 Apr 2020 19:52:51 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id 23so643436qkf.0 for ; Tue, 28 Apr 2020 19:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZuYhQOwVqj5I2l0C3mwcWWBRC4vXsL2shmKKYh/lrQg=; b=aCmH7CwlwPl/0ya/suzFuA1fMGqaCRqlG1An9hZRxqlWrWA87i8lAzj19h17I7fVNY SkAcbxzKv2yVzNDU26bW9XPSlaGn08IkxBernQCD5ymMMy10wMAO4iA5SlJgrV6/rHaR UR10WckaYKHTF8QxLVBLYtLz+jd+e24vryNXvlfdrfdWXTi/pS4/yFmx45AuBPT1atFY e3xpNkyL5b2gkq9kVYEGW7ICo5ondTQiiXBy7zypoc2So3d00g3auY/sQKGU43yMdxoG ehNkl1Lxa29e4IJt1e3V3D0XETFGEopBpDd1nTLMoOy1Y1xIImQCuF2KMJqnHHy7H+M9 uy/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZuYhQOwVqj5I2l0C3mwcWWBRC4vXsL2shmKKYh/lrQg=; b=Gp+4ayq2x7SsRRXGQP1ZWd0RrkUClcvbqzrlyigf0v+oXhepArp7VE6KHnaB/Ha6Ra xUSM8TPeteKN2/oA2HqXJiO8Rv9sLi/eEO1yEXH45fwrLJsYQGZmyGbcELTkHq8b5+HD gqpuk4oJ91i9oOGwmzJQHMN1D3yExCn/pH0hZ4ekYQcYmZqH8db2O01eDyO1nAVux/sV Q/eSQj3Q/eQCTEPLVtxzJA1R7OTPgyQDray4s+p1AJvxN2d7GWHdYa/6M+ZXeZUoIoVX u1yUzbQmaemVLZsNWgRbBgClvdmyOG2ml0mJm5BEkF/QQf0zu60/55VPoaSrmVdyWKT8 igNg== X-Gm-Message-State: AGi0Pua9MqTWMWNiWZiT5AuwFbTXUv8/2rW1SAhLp7l4LrFgySuZzTBp ulscG0vsiNqO3Kp9O5h60/oD5A== X-Received: by 2002:a37:7b01:: with SMTP id w1mr31743791qkc.167.1588128771014; Tue, 28 Apr 2020 19:52:51 -0700 (PDT) Received: from [192.168.1.153] (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id t67sm14947399qka.17.2020.04.28.19.52.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2020 19:52:50 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v2 4/4] mm/slub: Fix sysfs shrink circular locking dependency From: Qian Cai In-Reply-To: <56327de0-fa44-d5f3-2409-69cf2b97a209@redhat.com> Date: Tue, 28 Apr 2020 22:52:48 -0400 Cc: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Johannes Weiner , Michal Hocko , Vladimir Davydov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Juri Lelli Content-Transfer-Encoding: quoted-printable Message-Id: <0310F66F-0ECB-43BF-B86F-3BDB74F51B06@lca.pw> References: <28BB8A1C-CFDF-4F5A-8686-537C3CE04818@lca.pw> <56327de0-fa44-d5f3-2409-69cf2b97a209@redhat.com> To: Waiman Long X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 28, 2020, at 10:06 AM, Waiman Long wrote: >=20 > On 4/27/20 10:11 PM, Qian Cai wrote: >>=20 >>> On Apr 27, 2020, at 9:39 PM, Waiman Long wrote: >>>=20 >>> The sequence that was prevented by this patch is "kn->count --> = mem_hotplug_lock.rwsem". This sequence isn't directly in the splat. Once = this link is broken, the 3-lock circular loop cannot be formed. Maybe I = should modify the commit log to make this point more clear. >> I don=E2=80=99t know what you are talking about. Once trylock succeed = once, you will have kn->count =E2=80=94> cpu/memory_hotplug_lock. >>=20 > Trylock is handled differently from lockdep's perspective as trylock = can failed. When trylock succeeds, the critical section is executed. As = long as it doesn't try to acquire another lock in the circular chain, = the execution will finish at some point and release the lock. On the = other hand, if another task has already held all those locks, the = trylock will fail and held locks should be released. Again, no deadlock = will happen. So once, CPU0 (trylock succeed): kn->count =E2=80=94> cpu/memory_hotplug_lock. Did you mean that lockdep will not record this existing chain? If it did. Then later, are you still sure that CPU1 (via memcg path = below) will still be impossible to trigger a splat just because lockdep = will be able to tell that those arennon-exclusive = (cpu/memory_hotplug_lock) locks instead? cpu/memory_hotplug_lock -> kn->count [ 290.805818] -> #3 (kn->count#86){++++}-{0:0}: [ 290.811954] __kernfs_remove+0x455/0x4c0 [ 290.816428] kernfs_remove+0x23/0x40 [ 290.820554] sysfs_remove_dir+0x74/0x80 [ 290.824947] kobject_del+0x57/0xa0 [ 290.828905] sysfs_slab_unlink+0x1c/0x20 [ 290.833377] shutdown_cache+0x15d/0x1c0 [ 290.837964] kmemcg_cache_shutdown_fn+0xe/0x20 [ 290.842963] kmemcg_workfn+0x35/0x50 <=E2=80=94=E2=80=94 = cpu/memory_hotplug_lock [ 290.847095] process_one_work+0x57e/0xb90 [ 290.851658] worker_thread+0x63/0x5b0 [ 290.855872] kthread+0x1f7/0x220 [ 290.859653] ret_from_fork+0x27/0x50=