Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1157674pxb; Fri, 21 Jan 2022 11:04:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHDBn+ucKbfBukcAnk5HldxA3EE3xX+clWcssvHsGhMswZrFT6BFRSx0/qE4wK3hBt/3BU X-Received: by 2002:a17:90a:4745:: with SMTP id y5mr2053618pjg.5.1642791885255; Fri, 21 Jan 2022 11:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642791885; cv=none; d=google.com; s=arc-20160816; b=e79+u9wIDiZB0jUwn801f6YpmLA0v//3zSDPVM/ij9XwJQ92bgahfFSRSSttJr631S MCIjW77FRR6rb3hKNVwzTEhUOO/S8o6Hm3wbAbMMeh+CKBtYkP3w69uwloHYh97BPGGW cUZk1AKxQWuOEYjQNeyxYBthQWOx0CS5xlhkIZdAquwGRzIFteUZRuwhFKGRbKQrzZTA My6fGv2QjIyzsakw6q72XgbAH9w3Xj7YUbTl0Z1CI27/Kn9zhleQw+yPjUiTXECfuds/ A0cmysw6PhqZJRIL9LSVDeRCpgR1pCl4Wy9wvmiLu2Zi9J3QTWhoqInGpvuLXnEbv29E Df+g== 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=kmxhGAX60wrjunqbjCCAgalS1xNjG4gQYc11az3AVr4=; b=g9Ac331qNM/G/pepncQkKrkJVMJp+9O/mAXGJH7fbi4VgvIw0S1YwLfwj3bAX8d2u1 1xNsj5RDh6ZoEAUxzyLb4R5EE/vVrSDOWOpeNsbcoo0ZGlqu70Hdfo4QHO/4t3Rq3vzp AnXNS4saPP3BNezvmwSGHv+q9knzGlsNfENphQzUigv3Ew6bgxAKrHacET0VTHQuuBHD ekwJVxzqsthCcZzjOGfNo+uqQj+pDVzn6wLCHigZ6OvkBwFHp3B1H60yd/Y4uVXc2z/g 5BDZ+xV07RxLAzhlHO0Yk1zxNXwt5MkIzt3JjwdkP71Cn3FfcOC3dw1vEgMmg51nFfh1 087w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QPnamv22; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si7066299pgr.699.2022.01.21.11.04.33; Fri, 21 Jan 2022 11:04:45 -0800 (PST) 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; dkim=pass header.i=@suse.com header.s=susede1 header.b=QPnamv22; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353002AbiASJU0 (ORCPT + 99 others); Wed, 19 Jan 2022 04:20:26 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:57526 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352985AbiASJUZ (ORCPT ); Wed, 19 Jan 2022 04:20:25 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A98ED21125; Wed, 19 Jan 2022 09:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642584024; 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=kmxhGAX60wrjunqbjCCAgalS1xNjG4gQYc11az3AVr4=; b=QPnamv229lqVT8gWP1H39M9eIW1NnK6TYGnE9yq6XuKZ7/FnsTmurANTXfSOhonzXoxHub AiaLl+b5E4gTbuZ2PM5I3qWDW6/DVt2u+JnGKncJHOAqx/ZNSDT6e/qJv+cH9VC76/3kei Lh9JOg91ST+wHWyIpIWyMtEKw+l5YoU= Received: from suse.cz (unknown [10.100.201.86]) (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 7A47FA3B81; Wed, 19 Jan 2022 09:20:24 +0000 (UTC) Date: Wed, 19 Jan 2022 10:20:22 +0100 From: Michal Hocko To: Minchan Kim Cc: Andrew Morton , David Hildenbrand , linux-mm , LKML , Suren Baghdasaryan , John Dias Subject: Re: [RESEND][PATCH v2] mm: don't call lru draining in the nested lru_cache_disable Message-ID: References: <20211230193627.495145-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 18-01-22 16:12:54, Minchan Kim wrote: > On Mon, Jan 17, 2022 at 02:47:06PM +0100, Michal Hocko wrote: > > On Thu 30-12-21 11:36:27, Minchan Kim wrote: > > > lru_cache_disable involves IPIs to drain pagevec of each core, > > > which sometimes takes quite long time to complete depending > > > on cpu's business, which makes allocation too slow up to > > > sveral hundredth milliseconds. Furthermore, the repeated draining > > > in the alloc_contig_range makes thing worse considering caller > > > of alloc_contig_range usually tries multiple times in the loop. > > > > > > This patch makes the lru_cache_disable aware of the fact the > > > pagevec was already disabled. With that, user of alloc_contig_range > > > can disable the lru cache in advance in their context during the > > > repeated trial so they can avoid the multiple costly draining > > > in cma allocation. > > > > Do you have any numbers on any improvements? > > The LRU draining consumed above 50% overhead for the 20M CMA alloc. This doesn't say much about the improvement itself. > > Now to the change. I do not like this much to be honest. LRU cache > > disabling is a complex synchronization scheme implemented in > > __lru_add_drain_all now you are stacking another level on top of that. > > > > More fundamentally though. I am not sure I understand the problem TBH. > > The problem is that kinds of IPI using normal prority workqueue to drain > takes much time depending on the system CPU business. How does this patch address that problem? The IPI has to happen at some point as we need to sync up with pcp caches. > > What prevents you from calling lru_cache_disable at the cma level in the > > first place? > > You meant moving the call from alloc_contig_range to caller layer? Yes. > So, virtio_mem_fake_online, too? It could and make sense from > performance perspective since upper layer usually calls the > alloc_contig_range multiple times on retrial loop. > > Havid said, semantically, not good in that why upper layer should > know how alloc_contig_range works(LRU disable is too low level stuff) > internally but I chose the performance here. > > There is an example why the stacking is needed. > cma_alloc also can be called from outside. > A usecase is try to call > > lru_cache_disable > for (order = 10; order >= 0; order) { > page = cma_alloc(1< if (page) > break; > } > lru_cacne_enable > > Here, putting the disable lru outside of cma_alloc is > much better than inside. That's why I put it outside. What does prevent you from calling lru_cache_{disable,enable} this way with the existing implementation? AFAICS calls can be nested just fine. Or am I missing something? -- Michal Hocko SUSE Labs