Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2427460pxf; Sat, 13 Mar 2021 21:20:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxotGMiZi7V4kgG47ax0M04y77qpT6XLYgT3KSRdZb6o2JFq+ItLrlPJcolRQXfpsTkCWSM X-Received: by 2002:a17:906:af6f:: with SMTP id os15mr17139693ejb.279.1615699250162; Sat, 13 Mar 2021 21:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615699250; cv=none; d=google.com; s=arc-20160816; b=GegYaYBbwIfQLE15tECkb5YRz0iGDXIwQnfxZI80pEDJ1vsjZE9j88tFaXB1kAlVyW SuUrTbF1UNuAwr4R+8yO6jq/XD2dXYq+Jsk1fCmyJ3h0x+Ch6ztElLgV51+HKYY/05QF sOJNuNDoUdeeUkp2VLRq1XA6vsOEk886zwmQfl1RoZgp2EG1/NnyoPKpKJxnLBA+xAPI 8YtUevBOETQ71ElFz/XKnnxi5S+UlxBY43H5WrzZdU7IP0uiZYqIyrwEFcb+ooyWHMJT 9vbYz/NdjiiHM9ecfe+e76wC94DwcRCvRdvAi83Q0LyHiHSXeBoPlRE9IIXZun11HD61 aCZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=0NoYkl/FuNu+r0+wsVoEHAF2YmV2p15GFH0+t+rZiNg=; b=OoonquhF2d9IngsAtQ0IVNZQoRKfubKG33qZVep9Gleyj5NIz/k8599fhxYhYz+DSf +K5lEguVSYwPetad5BXcPLD/8zubZ7HyL6OsJN1CNpmWPFB6gD96xc9VcwQ0yYkKECTT 4V5MXFYZX+9DRYe2p217OJiFEtdWi1w5+ZmacVdhM+OdXL6+mL6kTaBTdHW+2kwrYoZP u/tADuMmO2GxcxSq7HVDB0EQyQiQzCRLy1x0SmuKhkEhkUQrtA5gOIz7If9nR36XbpN6 bQQFK1/0D3wMtCDSKOSfhVVtfmmOaZSsdUpz4FE6gRwv0diN11N8wC3bj1wI3QQLd8Kq HG6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=n5hPPVSr; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si8311762ejy.142.2021.03.13.21.20.28; Sat, 13 Mar 2021 21:20:50 -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=@mg.codeaurora.org header.s=smtp header.b=n5hPPVSr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232662AbhCNFLE (ORCPT + 99 others); Sun, 14 Mar 2021 00:11:04 -0500 Received: from z11.mailgun.us ([104.130.96.11]:41636 "EHLO z11.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbhCNFKh (ORCPT ); Sun, 14 Mar 2021 00:10:37 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1615698637; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=0NoYkl/FuNu+r0+wsVoEHAF2YmV2p15GFH0+t+rZiNg=; b=n5hPPVSrEgmudPic5bfqe09tigCkA/T9lZXqdsPufKVLeYA2z/zmQayCov4oT6kR3+GfuesV jNIyXu/L9FdMbyVvVttn54h/KOtl0RKU7EWdj3rWolrOCdJGdstf5Lvlf5z3OuSgwDkp6kdn PJ/3D+0OXr3VRD+hTMySCAELTwk= X-Mailgun-Sending-Ip: 104.130.96.11 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 604d9ac85d70193f88dfb2a5 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sun, 14 Mar 2021 05:10:32 GMT Sender: cgoldswo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id AA79AC43464; Sun, 14 Mar 2021 05:10:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cgoldswo) by smtp.codeaurora.org (Postfix) with ESMTPSA id A8987C433C6; Sun, 14 Mar 2021 05:10:31 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 13 Mar 2021 21:10:31 -0800 From: Chris Goldsworthy To: Minchan Kim Cc: Andrew Morton , linux-mm , LKML , joaodias@google.com, surenb@google.com, willy@infradead.org, mhocko@suse.com, david@redhat.com, vbabka@suse.cz, linux-fsdevel@vger.kernel.org, Minchan Kim Subject: Re: [PATCH v3 2/3] mm: disable LRU pagevec during the migration temporarily In-Reply-To: <623d54ccbd5324bff22ad1389eae38f4@codeaurora.org> References: <20210310161429.399432-1-minchan@kernel.org> <20210310161429.399432-2-minchan@kernel.org> <623d54ccbd5324bff22ad1389eae38f4@codeaurora.org> Message-ID: X-Sender: cgoldswo@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-03-11 14:41, Chris Goldsworthy wrote: > On 2021-03-10 08:14, Minchan Kim wrote: >> LRU pagevec holds refcount of pages until the pagevec are drained. >> It could prevent migration since the refcount of the page is greater >> than the expection in migration logic. To mitigate the issue, >> callers of migrate_pages drains LRU pagevec via migrate_prep or >> lru_add_drain_all before migrate_pages call. >> >> However, it's not enough because pages coming into pagevec after the >> draining call still could stay at the pagevec so it could keep >> preventing page migration. Since some callers of migrate_pages have >> retrial logic with LRU draining, the page would migrate at next trail >> but it is still fragile in that it doesn't close the fundamental race >> between upcoming LRU pages into pagvec and migration so the migration >> failure could cause contiguous memory allocation failure in the end. >> >> To close the race, this patch disables lru caches(i.e, pagevec) >> during ongoing migration until migrate is done. >> >> Since it's really hard to reproduce, I measured how many times >> migrate_pages retried with force mode(it is about a fallback to a >> sync migration) with below debug code. >> >> int migrate_pages(struct list_head *from, new_page_t get_new_page, >> .. >> .. >> >> if (rc && reason == MR_CONTIG_RANGE && pass > 2) { >> printk(KERN_ERR, "pfn 0x%lx reason %d\n", page_to_pfn(page), >> rc); >> dump_page(page, "fail to migrate"); >> } >> >> The test was repeating android apps launching with cma allocation >> in background every five seconds. Total cma allocation count was >> about 500 during the testing. With this patch, the dump_page count >> was reduced from 400 to 30. >> >> The new interface is also useful for memory hotplug which currently >> drains lru pcp caches after each migration failure. This is rather >> suboptimal as it has to disrupt others running during the operation. >> With the new interface the operation happens only once. This is also >> in >> line with pcp allocator cache which are disabled for the offlining as >> well. >> >> Signed-off-by: Minchan Kim >> --- > > Hi Minchan, > > This all looks good to me - feel free to add a Reviewed-by from me. > > Thanks, > > Chris. Should have added: Reviewed-by: Chris Goldsworthy -- The Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project