From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7990EC83001 for ; Wed, 29 Apr 2020 02:52:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 33B9620775 for ; Wed, 29 Apr 2020 02:52:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="aCmH7Cwl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33B9620775 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BB6058E0005; Tue, 28 Apr 2020 22:52:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B662C8E0001; Tue, 28 Apr 2020 22:52:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA36E8E0005; Tue, 28 Apr 2020 22:52:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id 9444C8E0001 for ; Tue, 28 Apr 2020 22:52:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 480B9181AEF07 for ; Wed, 29 Apr 2020 02:52:52 +0000 (UTC) X-FDA: 76759370184.09.stick07_7050d76531116 X-HE-Tag: stick07_7050d76531116 X-Filterd-Recvd-Size: 5719 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Apr 2020 02:52:51 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id b188so592470qkd.9 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=JUl6mctAbATPtiKLt2oSplQa2Xu/0f9uUWNi3znqgcafvkHPsuwsS+q3MPPST2wpBN 1Bo36nh0dGHNU17U1qza/6ix3LZlouSk8a6/BHlSW++jEcQi4R/F2vewD70OHUbpXKzt yoTx4HS2Lj6lTORtHbqSgPz9INS46N2jrLTFd6mPjhkRWpfH7CzTHMM/gpyiCwn/0/P1 1z7KoNPeigNcfyf32zaOd+B9fKY431fyMGRukaxUPgfO4NvsBaF3huf+VPL5EXhJvSN8 lHzatf9EvcxviAjykiCk8p7QaGZiyW/imY9at2wcgzxZSojjOPWUSLmO9pzdNqeKisYO D5Pw== X-Gm-Message-State: AGi0Pubwdt12Gxy81iPbLa3WW/fv0TupSlspCcmn7zWnpXqc9GrbgsVB QBxcnr3503F+QjnR5fxxqqKKTQ== X-Google-Smtp-Source: APiQypJiO5xWI+h/pT4bi47A94HPt7b3SBuTMERGoOCtnJcgSOKc8ipTbQTSRssdaCLVDjQ5/LtWzQ== 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) 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: > 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=