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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC8F7C433EF for ; Fri, 1 Apr 2022 00:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243560AbiDAAfm (ORCPT ); Thu, 31 Mar 2022 20:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243548AbiDAAfk (ORCPT ); Thu, 31 Mar 2022 20:35:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E57B45749A; Thu, 31 Mar 2022 17:33:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 813E8617DC; Fri, 1 Apr 2022 00:33:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CF76C340EE; Fri, 1 Apr 2022 00:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648773231; bh=og4lU4dyrILrjlo8MbO414DxVtLpdEFdDjD3sS0QOBw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=U5o07Jxr93Bh9u6zSuP89IQcL92kcAZ770UBXZgKYQhmAKYXLDrkqGlg6AvIB0FHv 14Swf4CBx/hO7N8YcVLLInn2Sfp3NjT3dBk628qB+FYc9C4Z8jZZDhJLwXD6RMXoFP B5npudLXVCs+sY72+8rR2+3cyLmHtzPdxAJZykjk= Date: Thu, 31 Mar 2022 17:33:50 -0700 From: Andrew Morton To: Yosry Ahmed Cc: Johannes Weiner , Michal Hocko , Shakeel Butt , David Rientjes , Tejun Heo , Zefan Li , Roman Gushchin , cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonathan Corbet , Yu Zhao , Dave Hansen , Wei Xu , Greg Thelen Subject: Re: [PATCH resend] memcg: introduce per-memcg reclaim interface Message-Id: <20220331173350.1fe09370479a4a6f916b477d@linux-foundation.org> In-Reply-To: <20220331084151.2600229-1-yosryahmed@google.com> References: <20220331084151.2600229-1-yosryahmed@google.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 31 Mar 2022 08:41:51 +0000 Yosry Ahmed wrote: > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -6355,6 +6355,38 @@ static ssize_t memory_oom_group_write(struct kernfs_open_file *of, > return nbytes; > } > > +static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf, > + size_t nbytes, loff_t off) > +{ > + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); > + unsigned int nr_retries = MAX_RECLAIM_RETRIES; > + unsigned long nr_to_reclaim, nr_reclaimed = 0; > + int err; > + > + buf = strstrip(buf); > + err = page_counter_memparse(buf, "", &nr_to_reclaim); > + if (err) > + return err; > + > + while (nr_reclaimed < nr_to_reclaim) { > + unsigned long reclaimed; > + > + if (signal_pending(current)) > + break; > + > + reclaimed = try_to_free_mem_cgroup_pages(memcg, > + nr_to_reclaim - nr_reclaimed, > + GFP_KERNEL, true); > + > + if (!reclaimed && !nr_retries--) > + break; > + > + nr_reclaimed += reclaimed; > + } Is there any way in which this can be provoked into triggering the softlockup detector? Is it optimal to do the MAX_RECLAIM_RETRIES loop in the kernel? Would additional flexibility be gained by letting userspace handle retrying? From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH resend] memcg: introduce per-memcg reclaim interface Date: Thu, 31 Mar 2022 17:33:50 -0700 Message-ID: <20220331173350.1fe09370479a4a6f916b477d@linux-foundation.org> References: <20220331084151.2600229-1-yosryahmed@google.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648773231; bh=og4lU4dyrILrjlo8MbO414DxVtLpdEFdDjD3sS0QOBw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=U5o07Jxr93Bh9u6zSuP89IQcL92kcAZ770UBXZgKYQhmAKYXLDrkqGlg6AvIB0FHv 14Swf4CBx/hO7N8YcVLLInn2Sfp3NjT3dBk628qB+FYc9C4Z8jZZDhJLwXD6RMXoFP B5npudLXVCs+sY72+8rR2+3cyLmHtzPdxAJZykjk= In-Reply-To: <20220331084151.2600229-1-yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" To: Yosry Ahmed Cc: Johannes Weiner , Michal Hocko , Shakeel Butt , David Rientjes , Tejun Heo , Zefan Li , Roman Gushchin , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Jonathan Corbet , Yu Zhao , Dave Hansen , Wei Xu , Greg Thelen On Thu, 31 Mar 2022 08:41:51 +0000 Yosry Ahmed wrote: > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -6355,6 +6355,38 @@ static ssize_t memory_oom_group_write(struct kernfs_open_file *of, > return nbytes; > } > > +static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf, > + size_t nbytes, loff_t off) > +{ > + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); > + unsigned int nr_retries = MAX_RECLAIM_RETRIES; > + unsigned long nr_to_reclaim, nr_reclaimed = 0; > + int err; > + > + buf = strstrip(buf); > + err = page_counter_memparse(buf, "", &nr_to_reclaim); > + if (err) > + return err; > + > + while (nr_reclaimed < nr_to_reclaim) { > + unsigned long reclaimed; > + > + if (signal_pending(current)) > + break; > + > + reclaimed = try_to_free_mem_cgroup_pages(memcg, > + nr_to_reclaim - nr_reclaimed, > + GFP_KERNEL, true); > + > + if (!reclaimed && !nr_retries--) > + break; > + > + nr_reclaimed += reclaimed; > + } Is there any way in which this can be provoked into triggering the softlockup detector? Is it optimal to do the MAX_RECLAIM_RETRIES loop in the kernel? Would additional flexibility be gained by letting userspace handle retrying?