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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 643E9C35E04 for ; Tue, 25 Feb 2020 14:58:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B61921744 for ; Tue, 25 Feb 2020 14:58:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B61921744 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 B7E296B0003; Tue, 25 Feb 2020 09:58:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B2D766B0005; Tue, 25 Feb 2020 09:58:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A43806B0006; Tue, 25 Feb 2020 09:58:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 8CD5E6B0003 for ; Tue, 25 Feb 2020 09:58:32 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4F7EB180AD802 for ; Tue, 25 Feb 2020 14:58:32 +0000 (UTC) X-FDA: 76528955664.11.sleep86_6794c50e42c1f X-HE-Tag: sleep86_6794c50e42c1f X-Filterd-Recvd-Size: 5546 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Feb 2020 14:58:31 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id j7so2564919wrp.13 for ; Tue, 25 Feb 2020 06:58:31 -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=0UgZMjEYrhnpUW+KD5jOXcu9LxkZxjWZEpMnARZ+WD0=; b=FyOvhK+52HygBleFM7xdw6+OIWQqopmn8KKWrjNLQ/4oulOSIdRIu/EGy9F2Qh1eL3 PSn9KHQy5gAs57Q7+U4yx+gqCoSU+yjuYH/uoWN59TMDdcBmto9TfOIVO6pUjszDwHuc ma7MbVDQ75MfVrH88FJrvkelWWqbDfoMH2luHLQi7Dyf94oH6xDy+n8zx9zeFB9l0NXH i9dhqebyfAP4X/vZFmE8Go7Ep9K9Cha7Szn7unJJSsgVfCtnaI8K1+hB8/nuiFq1N8eL ynrFkjdEaeBbV7MlVbS6czerLI15KG5SxYw3wOgqSdiv8R5xOTF8MIcFBiKl4c1dLUsQ Nzyw== X-Gm-Message-State: APjAAAUK1PJv7eb0GyVmYRHCEboSbi5di3VAdTnLsgllL8d8RPij0uFe jbx2lhpjzboDxkJ7uSvQuhI= X-Google-Smtp-Source: APXvYqzpdPx0S/Ay341l/1VLTiTEph73dZr8/CzTbfXsVdnLAYyHzJiSa2C64DI7Obv90MD62NKfOw== X-Received: by 2002:adf:c445:: with SMTP id a5mr2759044wrg.14.1582642710508; Tue, 25 Feb 2020 06:58:30 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id p5sm23820841wrt.79.2020.02.25.06.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 06:58:29 -0800 (PST) Date: Tue, 25 Feb 2020 15:58:29 +0100 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtio-dev@lists.oasis-open.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, Andrew Morton , "Michael S . Tsirkin" Subject: Re: [PATCH RFC v4 12/13] mm/vmscan: Export drop_slab() and drop_slab_node() Message-ID: <20200225145829.GW22443@dhcp22.suse.cz> References: <20191212171137.13872-1-david@redhat.com> <20191212171137.13872-13-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191212171137.13872-13-david@redhat.com> 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 Thu 12-12-19 18:11:36, David Hildenbrand wrote: > We already have a way to trigger reclaiming of all reclaimable slab objects > from user space (echo 2 > /proc/sys/vm/drop_caches). Let's allow drivers > to also trigger this when they really want to make progress and know what > they are doing. I cannot say I would be fan of this. This is a global action with user visible performance impact. I am worried that we will find out that all sorts of drivers have a very good idea that dropping slab caches is going to help their problem whatever it is. We have seen the same patter in the userspace already and that is the reason we are logging the usage to the log and count invocations in the counter. > virtio-mem wants to use these functions when it failed to unplug memory > for quite some time (e.g., after 30 minutes). It will then try to > free up reclaimable objects by dropping the slab caches every now and > then (e.g., every 30 minutes) as long as necessary. There will be a way to > disable this feature and info messages will be logged. > > In the future, we want to have a drop_slab_range() functionality > instead. Memory offlining code has similar demands and also other > alloc_contig_range() users (e.g., gigantic pages) could make good use of > this feature. Adding it, however, requires more work/thought. We already do have a memory_notify(MEM_GOING_OFFLINE) for that purpose and slab allocator implements a callback (slab_mem_going_offline_callback). The callback is quite dumb and it doesn't really try to free objects from the given memory range or even try to drop active objects which might turn out to be hard but this sounds like a more robust way to achieve what you want. > Cc: Andrew Morton > Cc: Michal Hocko > Signed-off-by: David Hildenbrand > --- > include/linux/mm.h | 4 ++-- > mm/vmscan.c | 2 ++ > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 64799c5cb39f..483300f58be8 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2706,8 +2706,8 @@ int drop_caches_sysctl_handler(struct ctl_table *, int, > void __user *, size_t *, loff_t *); > #endif > > -void drop_slab(void); > -void drop_slab_node(int nid); > +extern void drop_slab(void); > +extern void drop_slab_node(int nid); > > #ifndef CONFIG_MMU > #define randomize_va_space 0 > diff --git a/mm/vmscan.c b/mm/vmscan.c > index c3e53502a84a..4e1cdaaec5e6 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -719,6 +719,7 @@ void drop_slab_node(int nid) > } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); > } while (freed > 10); > } > +EXPORT_SYMBOL(drop_slab_node); > > void drop_slab(void) > { > @@ -728,6 +729,7 @@ void drop_slab(void) > drop_slab_node(nid); > count_vm_event(DROP_SLAB); > } > +EXPORT_SYMBOL(drop_slab); > > static inline int is_page_cache_freeable(struct page *page) > { > -- > 2.23.0 -- Michal Hocko SUSE Labs