Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp772755pxf; Thu, 11 Mar 2021 14:43:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1ogI+LD7Krspoa2VJpg1AeEj3w32w6ZPEf0KWngvAWH5yGCud9dxIBUIZEzar7K4/NSVF X-Received: by 2002:a17:906:75a:: with SMTP id z26mr5308919ejb.22.1615502636436; Thu, 11 Mar 2021 14:43:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615502636; cv=none; d=google.com; s=arc-20160816; b=VhigmjvNV12IYXjaCseznuZU7JojKEGHi+vH4j5l8h66Lqcr3SF5++Bei0CP2/l9pf kPjeq0s6cWKa4hxA93S6rBNwjGGtTY588u8pc9rvH08i1ebA4LyZpm9EUSCBpIS8G3TB gk7xflPhMScKV7NkXaANSTgkLRbZPEzSNaKJVah+R955WFKmganHdUC3Xk3cKhoawSE2 fLqsmPt/9emLopmS1PIwnkPYPdeesCUoS/WCD+y3zrYWSGymxxxIbK8qGCoALGyUMs4u xcBGtdBFeDhPg29atZPDY4q8OtkywJSME/ry2xAAHiYW7Y+VgQ74Z+iPa1HhEGCsHx6E qTDQ== 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=P6svW8ngSg504NS77cpkUbs73VgoaaSVMOcJWpi/Exs=; b=YxIYXYxzo8D7xmpIYYIP8tzhWfoxbWqeCDAftAzNuE6dNi50SkqVofLGhv+UKmSk32 oqxXZeljHnMO3MvHDIvykF98d9PBM08N98S0t4J9oAyfrfxdLUOcHviO+oFwFTaXCRXS CYESCnRQlrec+ZJTtdzfNtuCxjRRdQiK0WqhQVCQg9puN5zpI9JZmbbkYYmoFj/nE2T2 xUvh+5mi4Xg9OWqC9ofWybAYqGRCkAkhG/Eskx54gBOzn04eKqeHrJoUi1PpWq1qBkSn znsJbPqj4qaQmJj6SCt4rhI5OCL3nwtkqhGcMdRE3qoQF0sehxfLfh3Yp6N03Tjt014U jEug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="A/19ZBDI"; 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 17si2698117ejv.562.2021.03.11.14.43.33; Thu, 11 Mar 2021 14:43:56 -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="A/19ZBDI"; 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 S229574AbhCKWmE (ORCPT + 99 others); Thu, 11 Mar 2021 17:42:04 -0500 Received: from m42-2.mailgun.net ([69.72.42.2]:51876 "EHLO m42-2.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbhCKWl4 (ORCPT ); Thu, 11 Mar 2021 17:41:56 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1615502515; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=P6svW8ngSg504NS77cpkUbs73VgoaaSVMOcJWpi/Exs=; b=A/19ZBDIDMPnuozHjPxqQWiMrf4f49LAJ72GI4WKbI5RldK6cyDHc6YbQVUJCVxGRYHzhfRX mXoAoNgBiujY7i/LWkkMyDcJFArakWQ3JShqznHDHzz/fwwz34zv/ztenXiqBYX0Z8nrBMdu duz7vHD6egxTl0hPNbUNX9s57gY= X-Mailgun-Sending-Ip: 69.72.42.2 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-n06.prod.us-east-1.postgun.com with SMTP id 604a9c9b6dc1045b7d014eb4 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 11 Mar 2021 22:41:31 GMT Sender: cgoldswo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 4C2C6C43464; Thu, 11 Mar 2021 22:41:31 +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 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 579A6C433C6; Thu, 11 Mar 2021 22:41:30 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 11 Mar 2021 14:41:30 -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: <20210310161429.399432-2-minchan@kernel.org> References: <20210310161429.399432-1-minchan@kernel.org> <20210310161429.399432-2-minchan@kernel.org> Message-ID: <623d54ccbd5324bff22ad1389eae38f4@codeaurora.org> 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-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. -- The Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project