From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1DFBC433DB for ; Sun, 14 Mar 2021 05:10:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 836E564EC4 for ; Sun, 14 Mar 2021 05:10:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 836E564EC4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F2A8B6B0070; Sun, 14 Mar 2021 00:10:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EDB3B6B0071; Sun, 14 Mar 2021 00:10:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D53F56B0072; Sun, 14 Mar 2021 00:10:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id B78F56B0070 for ; Sun, 14 Mar 2021 00:10:52 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6A2466D91 for ; Sun, 14 Mar 2021 05:10:52 +0000 (UTC) X-FDA: 77917305144.06.68EAF92 Received: from z11.mailgun.us (z11.mailgun.us [104.130.96.11]) by imf19.hostedemail.com (Postfix) with ESMTP id 087B490009E2 for ; Sun, 14 Mar 2021 05:10:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1615698650; 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=oIrW1aQSwaSZYZ0/FEgfFcXFcPq577eqjaiczYSarpOfl03t1IOXOOyJYOYcd+H5ot04BWWl knNQ5r4qzBn6vfNWishEHzSKsoOlDWmoetQpk9p7tixG+5FkX96bHQEjMqt1YlWYYM7lbPRz WY40jx9u8IinuEzYaSWRGu8Uwzs= X-Mailgun-Sending-Ip: 104.130.96.11 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 604d9ac94db3bb68011ff3b8 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sun, 14 Mar 2021 05:10:33 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 9B116C43462; Sun, 14 Mar 2021 05:10:32 +0000 (UTC) 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 X-Stat-Signature: 7hw3imiw64q3zfysi1c3hianrsur9mtt X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 087B490009E2 Received-SPF: none (mg.codeaurora.org>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=z11.mailgun.us; client-ip=104.130.96.11 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615698648-530227 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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