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.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, 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 975DAC33CA4 for ; Fri, 10 Jan 2020 21:27:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5A8B820838 for ; Fri, 10 Jan 2020 21:27:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="vdr15sBS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A8B820838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C998C8E0005; Fri, 10 Jan 2020 16:27:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C4A7D8E0001; Fri, 10 Jan 2020 16:27:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3A1D8E0005; Fri, 10 Jan 2020 16:27:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 995348E0001 for ; Fri, 10 Jan 2020 16:27:37 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 2D7E3181AEF00 for ; Fri, 10 Jan 2020 21:27:37 +0000 (UTC) X-FDA: 76363011354.18.stage03_5f68172d69f3b X-HE-Tag: stage03_5f68172d69f3b X-Filterd-Recvd-Size: 5728 Received: from mail-oi1-f195.google.com (mail-oi1-f195.google.com [209.85.167.195]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Fri, 10 Jan 2020 21:27:35 +0000 (UTC) Received: by mail-oi1-f195.google.com with SMTP id d62so3122217oia.11 for ; Fri, 10 Jan 2020 13:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Dc7C9t8nS5kMbHGnuaUU5Fa2JKAfraVFXFnxYmWF9bM=; b=vdr15sBSjoi3j4oUEH5jIDurHcvUNEyEW57q0WyAtFekwNzRnrjVwYvA8hPQQXbIqE DIxI19JZ1HDadWeoreEH4fXrqQS6trIV7O3FllR4i+G+aEL6ola42rSNyRj+JKzuBQJg poxz2gLWMzx9yD4J50Q4EZbvfDmuFpTP+6TJMWgk5k1kAmgqgjVnyCzbihiEAa/YyXWD w+GHu+xvWtvJrZ8/PaY4qmaoEuBqjMoLpFt9DmoSAuQDTXmo/T46CPcZDt8AtupbXqvd 1VA3Obwi7t67dWTJ2rJsjPNBNgBk9Bn+dFa6CMsRBhLfEOYfgzH8j9iz/ydo0XmyN5RN 7vhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Dc7C9t8nS5kMbHGnuaUU5Fa2JKAfraVFXFnxYmWF9bM=; b=pvCZjSXTmou/I4wIwynwQ0OvlWMUvAtlX96Zradv+2zacIxLdV6dktmgxtiswuIUO/ K2UqCl2s1KnlCN+pAoBYr0uxgaXKLJKXP48ATvWFpkPSINMYYWivNVFtsEpvJY3DwYW+ 4oFZCw9djhV2K1IDWTszpkuE+WnVMK31OmxReclvj2rjcaIP7gogyGZG4nmAKcAXRKvf Jj9623YLjUzAy2UqKvha/WZI2vCnWcWFSQmH6r99uL1071AC99NORMgfi9CNk3kukn3P Khky8wMhUdYGgdon4gJfVaSvDJgBoFV7vZJYJ6USAWM/UvnSTH0rXoXg/TY6GGKE2t6t SX/g== X-Gm-Message-State: APjAAAXHCWaZ7WZZa+H4c5UArjfZ+OytfJvYjNNnQtcVKQh//6ZwNdkJ WGLw9fUyK8eqL/xby1E5UNO5eqhcABrp8oihf2g7Bw== X-Google-Smtp-Source: APXvYqxNQu1g9Swlj4ItY7HDQzDpLpZJ3izCmtZ6N6CCpd39vuCJadEa4YSBiWIqE+WMu6DZXNyq9S4tBDEBiKXq8Uo= X-Received: by 2002:aca:4c9:: with SMTP id 192mr4108696oie.105.1578691654771; Fri, 10 Jan 2020 13:27:34 -0800 (PST) MIME-Version: 1.0 References: <157863061737.2230556.3959730620803366776.stgit@dwillia2-desk3.amr.corp.intel.com> <4d0334e2-c4e7-6d3f-99ba-2ca0495e1549@redhat.com> <64902066-51dd-9693-53fc-4a5975c58409@redhat.com> <516aa930-9b64-b377-557c-5413ed9fe336@redhat.com> In-Reply-To: <516aa930-9b64-b377-557c-5413ed9fe336@redhat.com> From: Dan Williams Date: Fri, 10 Jan 2020 13:27:24 -0800 Message-ID: Subject: Re: [PATCH] mm/memory_hotplug: Fix remove_memory() lockdep splat To: David Hildenbrand Cc: Andrew Morton , stable , Vishal Verma , Pavel Tatashin , Michal Hocko , Dave Hansen , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" 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 Fri, Jan 10, 2020 at 9:42 AM David Hildenbrand wrote: > > On 10.01.20 18:39, Dan Williams wrote: > > On Fri, Jan 10, 2020 at 9:36 AM David Hildenbrand wrote: > >> > >> On 10.01.20 18:33, Dan Williams wrote: > >>> On Fri, Jan 10, 2020 at 9:29 AM David Hildenbrand wrote: > >>> [..] > >>>>> So then the comment is actively misleading for that case. I would > >>>>> expect an explicit _unlocked path for that case with a comment about > >>>>> why it's special. Is there already a comment to that effect somewhere? > >>>>> > >>>> > >>>> __add_memory() - the locked variant - is called from the same ACPI location > >>>> either locked or unlocked. I added a comment back then after a longe > >>>> discussion with Michal: > >>>> > >>>> drivers/acpi/scan.c: > >>>> /* > >>>> * Although we call __add_memory() that is documented to require the > >>>> * device_hotplug_lock, it is not necessary here because this is an > >>>> * early code when userspace or any other code path cannot trigger > >>>> * hotplug/hotunplug operations. > >>>> */ > >>>> > >>>> > >>>> It really is a special case, though. > >>> > >>> That's a large comment block when we could have just taken the lock. > >>> There's probably many other code paths in the kernel where some locks > >>> are not necessary before userspace is up, but the code takes the lock > >>> anyway to minimize the code maintenance burden. Is there really a > >>> compelling reason to be clever here? > >> > >> It was a lengthy discussion back then and I was sharing your opinion. I > >> even had a patch ready to enforce that we are holding the lock (that's > >> how I identified that specific case in the first place). > > > > Ok, apologies I missed that opportunity to back you up. Michal, is > > this still worth it? > > > > For your reference (roughly 5 months ago, so not that old) > > https://lkml.kernel.org/r/20190724143017.12841-1-david@redhat.com Oh, now I see the problem. You need to add that lock so far away from the __add_memory() to avoid lock inversion problems with the acpi_scan_lock. The organization I was envisioning would not work without deeper refactoring.