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=-1.0 required=3.0 tests=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 32259C2D0CE for ; Tue, 21 Jan 2020 12:07:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3E942073A for ; Tue, 21 Jan 2020 12:07:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3E942073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8485F6B0008; Tue, 21 Jan 2020 07:07:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F9406B000A; Tue, 21 Jan 2020 07:07:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70EF86B000C; Tue, 21 Jan 2020 07:07:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 58A186B0008 for ; Tue, 21 Jan 2020 07:07:18 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 1C8D84435 for ; Tue, 21 Jan 2020 12:07:18 +0000 (UTC) X-FDA: 76401516156.05.grain45_3faaf61ab535f X-HE-Tag: grain45_3faaf61ab535f X-Filterd-Recvd-Size: 6173 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Jan 2020 12:07:17 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id d16so2869765wre.10 for ; Tue, 21 Jan 2020 04:07:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8+eTFTZWY1O+bS0tfQzZZHJ2QVfVqRuc9/acRYq78eE=; b=km3vxrCtb6VtHrM5FlwLV95Bwr46o1fTeDgy5O49cs4AWnIh8Q2zLMB6iOr+6V57n3 3SIap2mrKe8KQcLDKyhptUxOYnrG/90VlZABTqQSuj4yYpd/jEWpW9xxP5IP5b+Vs9ui ZDuwsLy4QEm+Hj3BvnzRMu9Uux9sPykFHT8ddLXHaPI24S9meG6YD7euJEGBRXd7xtOI SFaunG2HxfTWJG0G3cbPLzgfuNyVwCwwVOdGF2AyindVlkeGZBex/45o9oUahQV1stEi 2oJxNUs+36pZvsj0Sip7x8XxDK5hzlQHWhc/8nMrj9aRdmFBgbI11txXFOksgQRa6UeB LXSg== X-Gm-Message-State: APjAAAU13meoyd27Yx+EcryvONCmoxZvAbYZbF6GE4+vsKpLcVcio04m IJndABgADpvFpJP74AZAU9I= X-Google-Smtp-Source: APXvYqyxpUkI3wcRNy1BJM6GIVX1qC65Wu9WoeWHqPOsSl8LeuToreKpatoaJ2IPUby2HJ4XnSMCzg== X-Received: by 2002:adf:f8c8:: with SMTP id f8mr4797172wrq.331.1579608436190; Tue, 21 Jan 2020 04:07:16 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id z83sm3932163wmg.2.2020.01.21.04.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 04:07:14 -0800 (PST) Date: Tue, 21 Jan 2020 13:07:14 +0100 From: Michal Hocko To: David Hildenbrand Cc: Dan Williams , Linux Kernel Mailing List , Linux MM , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Leonardo Bras , Nathan Lynch , Allison Randal , Nathan Fontenot , Thomas Gleixner , Stephen Rothwell , Anshuman Khandual , lantianyu1986@gmail.com, linuxppc-dev Subject: Re: [PATCH RFC v1] mm: is_mem_section_removable() overhaul Message-ID: <20200121120714.GJ29276@dhcp22.suse.cz> References: <20200117113353.GT19428@dhcp22.suse.cz> <20200117145233.GB19428@dhcp22.suse.cz> <65606e2e-1cf7-de3b-10b1-33653cb41a52@redhat.com> <20200117152947.GK19428@dhcp22.suse.cz> <25a94f61-46a1-59a6-6b54-8cc6b35790d2@redhat.com> <20200120074816.GG18451@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon 20-01-20 10:14:44, David Hildenbrand wrote: > On 20.01.20 08:48, Michal Hocko wrote: > > On Fri 17-01-20 08:57:51, Dan Williams wrote: > > [...] > >> Unless the user is willing to hold the device_hotplug_lock over the > >> evaluation then the result is unreliable. > > > > Do we want to hold the device_hotplug_lock from this user readable file > > in the first place? My book says that this just waits to become a > > problem. > > It was the "big hammer" solution for this RFC. > > I think we could do with a try_lock() on the device_lock() paired with a > device->removed flag. The latter is helpful for properly catching zombie > devices on the onlining/offlining path either way (and on my todo list). try_lock would be more considerate. It would at least make any potential hammering a bit harder. > > Really, the interface is flawed and should have never been merged in the > > first place. We cannot simply remove it altogether I am afraid so let's > > at least remove the bogus code and pretend that the world is a better > > place where everything is removable except the reality sucks... > > As I expressed already, the interface works as designed/documented and > has been used like that for years. It seems we do differ in the usefulness though. Using a crappy interface for years doesn't make it less crappy. I do realize we cannot remove the interface but we can remove issues with the implementation and I dare to say that most existing users wouldn't really notice. > I tend to agree that it never should have been merged like that. > > We have (at least) two places that are racy (with concurrent memory > hotplug): > > 1. /sys/.../memoryX/removable > - a) make it always return yes and make the interface useless > - b) add proper locking and keep it running as is (e.g., so David can > identify offlineable memory blocks :) ). > > 2. /sys/.../memoryX/valid_zones > - a) always return "none" if the memory is online > - b) add proper locking and keep it running as is > - c) cache the result ("zone") when a block is onlined (e.g., in > mem->zone. If it is NULL, either mixed zones or unknown) > > At least 2. already scream for a proper device_lock() locking as the > mem->state is not stable across the function call. > > 1a and 2a are the easiest solutions but remove all ways to identify if a > memory block could theoretically be offlined - without trying > (especially, also to identify the MOVABLE zone). > > I tend to prefer 1b) and 2c), paired with proper device_lock() locking. > We don't affect existing use cases but are able to simplify the code + > fix the races. > > What's your opinion? Any alternatives? 1a) and 2c) if you ask me. -- Michal Hocko SUSE Labs