Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1297357pxb; Fri, 21 Jan 2022 14:41:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZQdNToBr0ja0XA/2Xmen9ZkUtSlmvMxdi8JPM6mKMZqanoZRCelxolY9KHFWnybaI13m4 X-Received: by 2002:a17:90b:4f8b:: with SMTP id qe11mr173776pjb.178.1642804888179; Fri, 21 Jan 2022 14:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642804888; cv=none; d=google.com; s=arc-20160816; b=ZEnT/yuAMVXr57WIGrT0NkFAwSS77w4oTaGGeRg6m5vbPqK8JT2S+s0BEcTgaKpEAP rq2cgH6Pbl1ScpIxZ7aw2isMJiUgCqrrQ+vFBrrVo+cuX42zBr9etcHzKKbt3uM+4DGt S2mJfCSVtr4tG07acPzPjEsXstSSf1kKBU7MdxinN2/SW7p7KgnBE1P2zaJ00ZslnR0i l5ZrlIyeqXNX8Z0u2wVND+Rhd8+aMMw+3sV8Ih0U61hCU0vpMJZ23zsa1HznNy1c+dx+ nWepQ9vcGAuE1AWfK9G0o0SST+H3uCbZzQ0gRz5eF2iMy/5wZLyEfZ3f0bqX6FWGQCob lc9g== 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:sender:dkim-signature; bh=CUsY6BC+pXhHFnLSqdEbGSsL6/Agpcnt4z12QyJauGo=; b=KRyToBNaDSr7S+co4PUPhDu3hG7NfIMMIb5oTiUT2GhWUTg3P74YGA2VqRm41SLTTW 4ylxO/JPsdEBpAGSYTHlljSDv9ImX5XasNuOCNBxIo6LjqrlMrclcjG+wqdo/IldZO0S par+Lzm1h58gFVodbXK67o2bxiZbbWNLoh3U7MKfHTh/ai9UbGxYjvcC1OWSmkt5TAu+ MqnEs+0ElOGVtyIDrjFXtq8alEMFj5PMDMk/G0HVd0o9Tt3WAXeEadjPKyjxzWegI+2g weCWo9GrNx346CCOp+pTyZ3fYeNPnack5LsqHSAc6ILfzRuaKpXpwn+/D32aPwGEVnOa PegQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GN39w31c; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d184si7661834pgc.100.2022.01.21.14.41.16; Fri, 21 Jan 2022 14:41:28 -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=@gmail.com header.s=20210112 header.b=GN39w31c; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377795AbiATVWv (ORCPT + 99 others); Thu, 20 Jan 2022 16:22:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231299AbiATVWu (ORCPT ); Thu, 20 Jan 2022 16:22:50 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C6EEC061574 for ; Thu, 20 Jan 2022 13:22:50 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id v74so3559012pfc.1 for ; Thu, 20 Jan 2022 13:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CUsY6BC+pXhHFnLSqdEbGSsL6/Agpcnt4z12QyJauGo=; b=GN39w31clbNaSPLsttHOH88mpjYQ/o/CpHxIQkhwgZIf/GjIQl4WjNTv8//y4vKEX4 JqR6xnUDR2n0F/E1LlPW33bp27QDLQMuAOTOZYSwjQ9czM2fUnNSUq1iwLrVGMViMro/ AqEAF2iI1v3wjYYhpgn3xYG43mW/Qb5Gdm4ppfgma3p7rOISH2mxi0vPDcbi5+OBgPSi QweNS1ewJ0jfHkzAMnECivsRGUsnfo5DSZa7kMnbCdK5qiCNVl0a5+RjbnGb+1K4BDqo ZqZNemG7ROhUW5yw2r2nA8+ndrPhmoNCqW3XtVeYUe8bnkyj6tQIXwOTL6567XVpX/JY EI6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=CUsY6BC+pXhHFnLSqdEbGSsL6/Agpcnt4z12QyJauGo=; b=bz4bM3V+Uwbu82I6Ty1OAoPW6xz+0eyZVRxxqAQvmGYg7M2hqwZLB4V3VKaASAIKMc uiPcNZ7VnfDRIpbLcoollb5yTSRRkj6LOGHJyVhpjbdv0G7GwnsEiFAeVCtlrsGwsbFr w6QuqFA/jIYodZ94mz9wJhtudAGuDFGWjh12N4CDz5uibB0DVcefaXC5kklcyrntM3Mn hOFohOBndb3nOPlFfq4vaGzvEiAzF6dNfeWasAKhGjyWWzY8GF9UylqUzcaNqZexMw6R K8U8k3c/bb+2ueAxk87Jj47sp7IzVSqk9cjXUtyuK0zWzC6d5/uLdimJvbrT6R81gsb8 zoSg== X-Gm-Message-State: AOAM533lTYsoD2w2tC/tNSzPiAkZLZ9wC12TtnXBfbl7aRyO1Z30ftU6 5tMx8hiqcMdsW2mt5y5eVVQ= X-Received: by 2002:a05:6a00:c92:b0:4c3:d3e:3674 with SMTP id a18-20020a056a000c9200b004c30d3e3674mr658218pfv.16.1642713769827; Thu, 20 Jan 2022 13:22:49 -0800 (PST) Received: from google.com ([2620:15c:211:201:b370:1e12:5bf4:801f]) by smtp.gmail.com with ESMTPSA id ca12sm3236486pjb.11.2022.01.20.13.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 13:22:49 -0800 (PST) Sender: Minchan Kim Date: Thu, 20 Jan 2022 13:22:47 -0800 From: Minchan Kim To: David Hildenbrand Cc: Michal Hocko , Andrew Morton , 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> <644356e5-2a85-fcea-2280-ff779ae8d38d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <644356e5-2a85-fcea-2280-ff779ae8d38d@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 09:42:23AM +0100, David Hildenbrand wrote: > On 19.01.22 01:12, 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. > > > >> > >> 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. > > > >> 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? > > 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. > > > > ^ I actually do have something like that on my TODO list. I'm glad to hear you are also looking the direction. If we move some information out of alloc_contig_range, upper layer has higher chance to make it fast. A example, "failure pfn and why it fails" > > The issue is that we have demanding requirements for > alloc_contig_range(), discussed in the past for CMA bulk allocations: > > (1) Fast, unreliable allocations > > Fail fast and let caller continue with next allocation instead of > retrying. Try to not degrade system performance. > > (2) Slow, reliable allocations > > Retry as good as possible. Degrading system performance (e.g., disabling > lru) is acceptable. "Fast and unreliable" provides lots of flexibilty for us to design since it's okay to fail. For "Slow, reliable", "the slow" should be not too much and we need to keep effort to make it faster.