Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp662620pxm; Wed, 2 Mar 2022 06:10:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaXIh5qPTnEqOGBAYszBT3oHFUd1++q8bpxOMHQD/JFZZzKNCRMpezrOTWf3Ye+HM8IcTg X-Received: by 2002:a17:90b:224d:b0:1bd:28ac:b9d8 with SMTP id hk13-20020a17090b224d00b001bd28acb9d8mr20234073pjb.1.1646230236010; Wed, 02 Mar 2022 06:10:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646230236; cv=none; d=google.com; s=arc-20160816; b=O44TIdMfG/PbqAt8m2cMD20NERTeT2QEuRhcUkfvEx3F9Yx/Tufm4cINtQD4FD39Y/ axMTHEBQ699XQ8AXQBRY3kxwnar1Jq4EcJfh6nd1M0Y/lNR/Ih8yFbIQgwkRYtfi5gPl ucIp4qEW8Ijy8N1OFsCuqkuQfuGtqx/cyape5ipJJC5z2mIcGs5fL6SP1oSzOETuEasd NtmovFnla7kSuS3JcxQUXv8ocw+F5Gyn9so/yeReDoQKg5FfL/hb02eF1XYHplTMkm04 Hsfse5CyQkbGO32raWF0OvgtntLwkf87zZAQup/zgMtQEUDhvO8IM0RL/9mIA/nrfJQF My/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j1HKAw1houAM0FOwreoChzGYlYJbkEiguoOSO4Ij0mk=; b=Ef5Iby/6PqVKh9R7IMRMPteKfl36abSZ9qdglu4cEhtox+XtITsPlo7Kt4BshUvx0C 1d/rHotGZsdslBZZvKQ2IEH8HXgP0MK41Q6qFsrSnT698/7xawI1hAGKZDgRbzHE26me DlSYxZxNdnXo/SBMNzkRCDs5kgNFCP0tMF+T+8+CyT+ZM9ctOMMN4BHBQtDdCwaB40bk ZdtD0hRtW7IMkEVnfib+0aLwc2l/jDs4PQf4NN1cEZeaiRBrORwsjK4G8DAOrn21rvhE wSihk+rcC67D1jBM+WS73KKDJUxWPme1vrAtBXkvGPIe1mrWfLzuVV9bhl0z7Pv1KuCZ zJqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=LPbeqbPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a631e48000000b003743bb48b13si14941315pgm.232.2022.03.02.06.10.17; Wed, 02 Mar 2022 06:10:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=LPbeqbPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241722AbiCBMTd (ORCPT + 99 others); Wed, 2 Mar 2022 07:19:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239514AbiCBMTc (ORCPT ); Wed, 2 Mar 2022 07:19:32 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F06037A1A for ; Wed, 2 Mar 2022 04:18:49 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 98597218E4; Wed, 2 Mar 2022 12:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1646223527; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=j1HKAw1houAM0FOwreoChzGYlYJbkEiguoOSO4Ij0mk=; b=LPbeqbPuJ1J4REL6P36Z4hWA1IupS4vOQUYodT2RbM2+duGJJCpnjmquhuIbXe6MeuCg6d InIMlK57yXDqCvaDnhs+9Gr+pTOup7f0YHpHnRh9zeyjp2WT71cOe2af84Qym6izb1+Dkd kCwlUAqOzKP7Gv0WnrGmOXvmKqbsuKQ= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 6FA2FA3B84; Wed, 2 Mar 2022 12:18:47 +0000 (UTC) Date: Wed, 2 Mar 2022 13:18:46 +0100 From: Petr Mladek To: Suren Baghdasaryan Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Peter Zijlstra , Roman Gushchin , Shakeel Butt , Minchan Kim , Tim Murray , linux-mm , LKML , kernel-team Subject: Re: [RFC 1/1] mm: page_alloc: replace mm_percpu_wq with kthreads in drain_all_pages Message-ID: References: <20220225012819.1807147-1-surenb@google.com> <20220301122520.GB23924@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2022-03-01 13:12:19, Suren Baghdasaryan wrote: > On Tue, Mar 1, 2022 at 4:25 AM Petr Mladek wrote: > > > > On Thu 2022-02-24 17:28:19, Suren Baghdasaryan wrote: > > > Sending as an RFC to confirm if this is the right direction and to > > > clarify if other tasks currently executed on mm_percpu_wq should be > > > also moved to kthreads. The patch seems stable in testing but I want > > > to collect more performance data before submitting a non-RFC version. > > > > > > > > > Currently drain_all_pages uses mm_percpu_wq to drain pages from pcp > > > list during direct reclaim. The tasks on a workqueue can be delayed > > > by other tasks in the workqueues using the same per-cpu worker pool. > > > This results in sizable delays in drain_all_pages when cpus are highly > > > contended. > > > Memory management operations designed to relieve memory pressure should > > > not be allowed to block by other tasks, especially if the task in direct > > > reclaim has higher priority than the blocking tasks. > > > Replace the usage of mm_percpu_wq with per-cpu low priority FIFO > > > kthreads to execute draining tasks. > > > > > > Suggested-by: Petr Mladek > > > Signed-off-by: Suren Baghdasaryan > > > > The patch looks good to me. See few comments below about things > > where I was in doubts. But I do not see any real problem with > > this approach. > > Thanks for the review, Petr. One question inline. Answering just this question. > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > > index 3589febc6d31..c9ab2cf4b05b 100644 > > > --- a/mm/page_alloc.c > > > +++ b/mm/page_alloc.c > > > +static void __init init_drain_workers(void) > > > +{ > > > + unsigned int cpu; > > > + > > > + for_each_online_cpu(cpu) > > > + alloc_drain_worker(cpu); > > > > I though whether this need to be called under cpus_read_lock(); > > And I think that the code should be safe as it is. There > > is this call chain: > > > > + kernel_init_freeable() > > + page_alloc_init_late() > > + init_drain_workers() > > > > It is called after smp_init() but before the init process > > is executed. I guess that nobody could trigger CPU hotplug > > at this state. So there there is no need to synchronize > > against it. > > Should I add a comment here to describe why we don't need > cpus_read_lock here (due to init process not being active at this > time)? I would add the comment. That said, I hope that I am right and lock is not really needed ;-) Best Regards, Petr