Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1655143ybk; Sat, 16 May 2020 19:02:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBcrnT5xE8tukzgmJjFjbYi2io1Ae/NKFzzT8/WhZY/Xs27CjhM2xZtL5B+ErCbr5g/Z7t X-Received: by 2002:a17:906:da0c:: with SMTP id fi12mr9217156ejb.254.1589680925852; Sat, 16 May 2020 19:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589680925; cv=none; d=google.com; s=arc-20160816; b=wbrFwQmCt1YRFfVqFW/qpKmOzWyytlDEaGS8yBTTzJTwUnPF+fwSDuqsvT9QOvG5Xg PjoMMybVZ4sjwizmue/oA3E9a0Bar35RSzyTDg8MYUhnL0wVhkEuCswGGHuquczoKK1X vIx2CHw90t9ph93r5yMCklJLhXmrcCy64G6SSSbztnAaxv5JgeoBM3o+BmFhpkWu6+BE ZL9eR7FwZI/6B+r1xNsGcMnIz0zUrOP8cSXLa7rfsoKnykFzwQSbVxpXiClZ+CNloTAP frUmLq7YA/coChvIoGbpa1YYxgZG7qoi5Cm4Ce38B7HjYsDSnNGdZLVAOpCIGfYDfmdV 1FfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=s3yeuZAhDmFpBOUorb/iouNYdnDc9CDj+UxZLN9lvxg=; b=uVVEywKrOjFrmU5fBTdYDtRXeW4yW2IH0iPlYwXNEhdm1hevKDrbGJoQDezz7dF5yI Dbj0TqK2FmteGWbFheEA9f6IKx1DMdmxOylUZqP0qq78wV2NlJktUj2yJR1RMBNd5XRI 477H7WLohnJmL9Nm5IK9STwr+kNEiDZmnr2nGMAwiOiuFORh4ZHUp+opHuO9UAcijQbA d6gLOxCvQptJO8KtkD3CXPwxE7ygoDtWBu7YkWYuZxRd4uvVir6kXiEEpsp9W4GuKF91 LAG7si+vXHJ/P5h/q9Cb2C0OwU7T0EUZd33vNWkCek/FzY2AJ+uJ4SSCcQXro83XEPq/ YNEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=nkDo28rE; 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 y8si356818ejf.120.2020.05.16.19.01.42; Sat, 16 May 2020 19:02:05 -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=nkDo28rE; 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 S1726932AbgEQB6C (ORCPT + 99 others); Sat, 16 May 2020 21:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbgEQB6B (ORCPT ); Sat, 16 May 2020 21:58:01 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B98DC061A0C for ; Sat, 16 May 2020 18:58:01 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id p4so3068211qvr.10 for ; Sat, 16 May 2020 18:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=s3yeuZAhDmFpBOUorb/iouNYdnDc9CDj+UxZLN9lvxg=; b=nkDo28rEL9kgR2hMhdY3aEgW0FJDqa7d8Al3/yHezV2tdkx30CmhQBcLfiTqOPrgjm ARxWaM3min6L9oyJv9TR/E2FlcMiEFBvPZi+GOOGp8QQxTSAD1A/0d1nDMyJMiJEBFlt cTisUARGGxzRNNipr3nyN4uDk6/wf1RqeFdZGbWd3rIOcAkAuj4SjJMXo2XR6Rte5iG/ T5gYipkgIEKTuHxcguMJWsNTk8+IgoOTRYVBFAdEG+tn2bDC8wbgLiiB+J0M8Uwnqbdm YuOZdqBrSRWUWn8mWck7nvrVHNn4YJ2VCn1Vwg1F8PbZqe145Ns41oZ15DEX/nBqYWRI W7YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=s3yeuZAhDmFpBOUorb/iouNYdnDc9CDj+UxZLN9lvxg=; b=AyLeqNwV0eIMnvNaVD/kdeXds76vHC99i6ma0QD4YqaBj+fBZXtS7oMa6Xgws52NDg EAQVy5qW/fYdL4GgOdSXgpnpXituW1Jer/MbJAqV8WR8I9HpxXWffrwBHH9Q05np9M5Y rVGwXfMzSscU+vkqZQALDdab2Yis0dobISSiNeR96j8fDTL0cYHUq2QBYK4r0/1kIZQr ZdLMKZuNTe2kIvkThXP2f8tp5RyvobINnqvcKum2pZ0XKi9NVVzfsU865/GvCi4587iu 0dm6JHTi8DUSDhOeM6JhU+yiRLfmkxvYwO67ksgiI4/w85DFOQoeKylnk548qmyQCDBq CZlA== X-Gm-Message-State: AOAM531fdqLDRb6spzvGg3vNwCY6kirtQiWQzquuzFrov+uTZXWLEsnE YbTg4WKU959e+VO+Rhi1fgPSjg== X-Received: by 2002:a0c:c603:: with SMTP id v3mr10304208qvi.82.1589680680311; Sat, 16 May 2020 18:58:00 -0700 (PDT) Received: from [192.168.1.183] (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id l184sm5080303qke.115.2020.05.16.18.57.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 May 2020 18:57:59 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable From: Qian Cai Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2 4/4] mm/slub: Fix sysfs shrink circular locking dependency Date: Sat, 16 May 2020 21:57:58 -0400 Message-Id: <3D1CF487-DD7E-4C5F-B977-D161CCED5234@lca.pw> References: <20200427235621.7823-5-longman@redhat.com> 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 In-Reply-To: <20200427235621.7823-5-longman@redhat.com> To: Waiman Long X-Mailer: iPhone Mail (17E262) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 27, 2020, at 7:56 PM, Waiman Long wrote: >=20 > A lockdep splat is observed by echoing "1" to the shrink sysfs file > and then shutting down the system: >=20 > [ 167.473392] Chain exists of: > [ 167.473392] kn->count#279 --> mem_hotplug_lock.rw_sem --> slab_mutex > [ 167.473392] > [ 167.484323] Possible unsafe locking scenario: > [ 167.484323] > [ 167.490273] CPU0 CPU1 > [ 167.494825] ---- ---- > [ 167.499376] lock(slab_mutex); > [ 167.502530] lock(mem_hotplug_lock.rw_sem= ); > [ 167.509356] lock(slab_mutex); > [ 167.515044] lock(kn->count#279); > [ 167.518462] > [ 167.518462] *** DEADLOCK *** >=20 > It is because of the get_online_cpus() and get_online_mems() calls in > kmem_cache_shrink() invoked via the shrink sysfs file. To fix that, we > have to use trylock to get the memory and cpu hotplug read locks. Since > hotplug events are rare, it should be fine to refuse a kmem caches > shrink operation when some hotplug events are in progress. >=20 > Signed-off-by: Waiman Long Feel free to use, Reviewed-by: Qian Cai =