Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3026919pxk; Mon, 7 Sep 2020 00:27:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxFQWAOaFuISqRn1eG99QGF2Q6RW8jH9ATF9KM3tve/5B+oLRU/cxySjlihzReDFXucct4 X-Received: by 2002:a17:907:2173:: with SMTP id rl19mr19341999ejb.514.1599463679590; Mon, 07 Sep 2020 00:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599463679; cv=none; d=google.com; s=arc-20160816; b=PYxuDru5mNJyv9rmYXjOWYvAdnqnJFzeTj94qJTsdyqvAl/6nDprdE7azRncUu5jHC mvpaKlSm9rVQZ+XG54gRrfFwKI34m/LR0Mke5RSmOGyMRdfo0LkclZCXUrVOoXj5IfOx lN9GffepuFgmXHn9KhXBkWFJVbmbrtgUAFTo+IbDPEEt8TnYSkT0X3Z7vmORQxi3sRgS PCDAbQTmCVqz80XcMDI8Xjv/PGRDZuIr7keDUUw9mlIoAIFVBt3Gjeu56Z6/AdhPHRiu RDYJtHW2BPUKpKKZsM7y7OWZDQ2AYrgcZD6u7GFC3+wzKLw6Syl3EBXGlHc/bKjxJkUp Y/Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Y1oe0zFfcv+goGPDEBZtm3j6y63aBZ6d26IGbWGhzWs=; b=i+MBWsgjGDZPYAVUsdvK0BZPM20KbW7z2DQ2RvcPcb//HAxcDONufVKu9WfyhqSmDW z38ir/QyZAaPhuxqxVAnuAACevMyi+qjJnIi9lzOrybfZw120qffDzYpJo5WBO8iHDG5 bIEHXOQpClsT1EFEXHBThHmXdr+FV5Dkn0mOek9/7joDMbGnj3m8H0ng9h5KyR0asqao CYSXIpH5udb1uiRv4keD2fSLsOlnt6LrKp+nm2ThhENNppRFgwsOEZjxc/w1MnTr+aCv CqbvKXM/hkZdgjjDYmms2huM4SSWBTp6th83KkCFTlPS3/2QLgEpnbd7zwZNzKYVnGOu liwQ== ARC-Authentication-Results: i=1; mx.google.com; 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 bs11si9058039edb.90.2020.09.07.00.27.36; Mon, 07 Sep 2020 00:27:59 -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; 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 S1726951AbgIGH0O (ORCPT + 99 others); Mon, 7 Sep 2020 03:26:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:40780 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbgIGH0K (ORCPT ); Mon, 7 Sep 2020 03:26:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0F480AD6B; Mon, 7 Sep 2020 07:26:10 +0000 (UTC) Date: Mon, 7 Sep 2020 09:26:08 +0200 From: Michal Hocko To: Pavel Tatashin Cc: David Hildenbrand , Vlastimil Babka , LKML , Andrew Morton , linux-mm Subject: Re: [PATCH] mm/memory_hotplug: drain per-cpu pages again during memory offline Message-ID: <20200907072608.GE30144@dhcp22.suse.cz> References: <74f2341a-7834-3e37-0346-7fbc48d74df3@suse.cz> <20200902151306.GL4617@dhcp22.suse.cz> <20200903063806.GM4617@dhcp22.suse.cz> <20200904070235.GA15277@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 04-09-20 10:25:02, Pavel Tatashin wrote: > > Another alternative would be to enable/disable static branch only from > > users who really care but this is quite tricky because how do you tell > > you need or not? It seems that alloc_contig_range would be just fine > > with a weaker semantic because it would "only" to a spurious failure. > > Memory hotplug on the other hand really needs to have a point where > > nobody interferes with the offlined memory so it could ask for a > > stronger semantic. > > > > Yet another option would be to make draining stronger and actually > > guarantee there are no in-flight pages to be freed to the pcp list. > > One way would be to tweak pcp->high and implement a strong barrier > > (IPI?) to sync with all CPUs. Quite expensive, especially when there are > > many draining requests (read cma users because hotplug doesn't really > > matter much as it happens seldom). > > > > So no nice&cheap solution I can think of... > > I think start_isolate_page_range() should not be doing page draining > at all. It should isolate ranges, meaning set appropriate flags, but > draining should be performed by the users when appropriate: next to > lru_add_drain_all() calls both in CMA and hotplug. I disagree. The pcp draining is an implementation detail and we shouldn't bother callers to be aware of it. > Currently, the way start_isolate_page_range() drains pages is very > inefficient. It calls drain_all_pages() for every valid page block, > which is a slow call as it starts a thread per cpu, and waits for > those threads to finish before returning. This is an implementation detail. > We could optimize by moving the drain_all_pages() calls from > set_migratetype_isolate() to start_isolate_page_range() and call it > once for every different zone, but both current users of this > interface guarantee that all pfns [start_pfn, end_pfn] are within the > same zone, and I think we should keep it this way, so again the extra > traversal is going to be overhead overhead. Again this just leads to tricky code. Just look at how easy it was to break this by removing something that looked clearly a duplicate call. It is true that memory isolation usage is limited to only few usecasaes but I would strongly prefer to make the semantic clear so that we do not repeat this regressions. -- Michal Hocko SUSE Labs