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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3879EC47DDF for ; Sat, 27 Jan 2024 16:23:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9D6F6B007B; Sat, 27 Jan 2024 11:23:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A4BE16B007D; Sat, 27 Jan 2024 11:23:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93A546B007E; Sat, 27 Jan 2024 11:23:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 852D86B007B for ; Sat, 27 Jan 2024 11:23:06 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 26BDF408B8 for ; Sat, 27 Jan 2024 16:23:06 +0000 (UTC) X-FDA: 81725610372.30.8AD4DE1 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 80A3618000D for ; Sat, 27 Jan 2024 16:23:04 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rqYs4I7p; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706372584; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5MZNQZ+U0qN5MQqp/SbJWOMILdkVqVbvXC98OckCEaY=; b=USbsfheoMGPeP+h4J9bM7/YpQkBBXrCJ/UZCGL1uucwgvHYaeALaTNGW6JjW+ZfalI1kkN JKkyKlDvu6qTEBrioZNwGQzwePS9tNl+a9tCW5Pfwon90qir4F6zGwVj2V2sgtPvqIb7WY A0ijDSCn/2csUARibpHp6dzudN3/KmA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rqYs4I7p; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706372584; a=rsa-sha256; cv=none; b=oou5DQORhQkpu4oDsnlu3xSktAk1qLrjNRf29TEigbY8nH+UUtdYInuWDfA6NNkQDzurrl AT/JK4AKX80QvMh+uQoznfj0wrWiqn+sa7PZsghixOINTekY26647T/oUPPFnO2tgP9BOH opE2SQu04vdFaKDJhkUZb7pFCajxNG0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=5MZNQZ+U0qN5MQqp/SbJWOMILdkVqVbvXC98OckCEaY=; b=rqYs4I7pZ1uOYVHIhQ1eakMTky xgx4C15f0/00wCdgi9w+JgeWxwvQXI4m5zt0xW9x1HgI8MB3/pSlrBYWyvgwwNeMygMCuxxDLIkPt LznO671hW7QiGV26CEanW4kgKOtg6pPianSOuKmxKgLYbPf7ohjtwlgnaqbEj6IkUA/tnrrdnNHkl r67/9lxhpcp1ykswGE1Kf92N5dKpB4/aJxKM+t8xa1V5KCy76D5c/jFU5UouJWmQRz1YJJqbmTavI Fs00/k4KhmC+WL1ygLW2KiV5ZaKYhaHU50ls9JEEDxnJdnJxYWzld8gnYSV8qUbQtWPlSfzieTztE eeDylA2w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTlSP-0000000HM6Z-0ryK; Sat, 27 Jan 2024 16:23:01 +0000 Date: Sat, 27 Jan 2024 16:23:01 +0000 From: Matthew Wilcox To: Haiqiang Gong =?utf-8?B?KOm+mua1t+W8uik=?= Cc: "linux-kernel@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "linux-arm-kernel@lists.infradead.org" , Mike Zhang =?utf-8?B?KOW8oOS8n+S8nyk=?= , "matthias.bgg@gmail.com" , "angelogioacchino.delregno@collabora.com" Subject: Re: =?utf-8?B?5Zue5aSNOiBbUEFUQ0g=?= =?utf-8?Q?=5D?= mm/compaction: add check mechanism to avoid cma alloc fail Message-ID: References: <20240122022317.30091-1-Haiqiang.Gong@mediatek.com> <0da9c1215291afeebe2cd99b0d8691c7fe6bde3a.camel@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0da9c1215291afeebe2cd99b0d8691c7fe6bde3a.camel@mediatek.com> X-Rspam-User: X-Stat-Signature: h74b5tq5shg9jfpt61s7wqdsrwr8nobc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 80A3618000D X-HE-Tag: 1706372584-398721 X-HE-Meta: U2FsdGVkX1+9YbdxMKsjJ0hAqvntJhORzM6e02ZUdWmvMZwWmYaDXPSi19NyySrjkVJog1bIokXaFzDRcy4iKxO9jtU/YeLfkoiWFDZbdFG/R4RF6effg5zIvHFmFRvLOCLUHfC2Vh+4n+xt059QRVp6CiBWZyb1jvnsNwffGm99r/o7tYsvECKgMMyusEdi+CXZnM4zCVhfJ8Os20nHYqMpTqnOYzIgJA/0Mp5c1jrOmStpYtULpvd4hbnDMkYyydUxKDmj62oJ3lM/JIaGd7eI0mUjyui9z4F1O3JOgNf6eQ2BQB5CX2EhY84XIJxjpP88DH4LrfuklR2TZR6YU//8YTUThkNawZEWLXRl+/IlFsfG0qkBvdk51BrfynPZdKmcPqBTEQSNceUDFCYpJODuItXCZmmp5PcxKxyd2aYXIv0hzo4V8szSvOxLgKwrKWaqk2hzT+pE+gCTCncDamkQzxrS7w7CvTU6oZQliaje2Nr8Y+QTZoO8Lm5NPWdzUYS37yvswjxoUtiHCb9iWdehGI/2bWgmy9kcgjBO1Ofq75yVF9Y8W52sNr2KI84eN0KY7vFBPFipnqIP2DX26tcOIItw/9+0wgzMD58zWnn32+meReX8w7xYlY39XPU/vE6fco0dNOKnshzmGhzx484ozWURz9bGvKT9yDu7iFmOwCLTiwvMi21OHQKwZEyFMHoTZjW24005b1TC20XpI+JlhHV8m4z8EM79c5sgceXrV4d5BDbxChtpK9VlIyDuxKNdS4AGpGS0hbASJDiKoCQKFZs1DT0l+XE5cW1KD/tjVgcHF3d1YWlb32vMfbZohxZtEfGEgACRgEWhos37iAOEccsHHE3EII8NCQ3AonDOc/wt3vUROi8sQnGlD+/rsv7sUnmlw31sXdXiLxwP3OtWokX8z+xqT2hp57nMBzn+wUJg8uGZ71z+nWZQvr/SYVmjSz0RTPb4CJPYZMP q9T+5x9e HK0WWltY7/7JCXpmG+GtrOZ4f9dMaywk2aT7+np81FhTaODLqGo2ClrSzonzHTeODrhL60tI6S2XU+wSFtVO04avyR6QchAqBniPEMuocNY3w+M7/h67bnWBO3hHe9U8cl210pR9SJIOAKHNvnEncOtd0qhcEuKQgGTGROnuzC/Aj2xgY1CU7dRUuwES/L4fjDY1A5uo/MbyVDLucHSVe7nMO/xC59Do5FLw0nrsBfLbvf/zGwnH3tPwOMAe2kCh0nY6ekVrdxkwcI8zEjeFrrn5m2g== 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: List-Subscribe: List-Unsubscribe: On Sat, Jan 27, 2024 at 11:03:48AM +0000, Haiqiang Gong (龚海强) wrote: > On Wed, 2024-01-24 at 18:40 +0000, Matthew Wilcox wrote: > > On Wed, Jan 24, 2024 at 07:20:53AM +0000, Haiqiang Gong (龚海强) wrote: > > > > I don't understand. You say that the memory isn't movable, but > > then you > > > > say that it's migrated in. So it was movable, but it's no longer > > > > movable after being moved once? > > > Sorry for not expressing clearly > > > When doing memory migration, the kernel will determine whether the > > current > > > page can be moved based on the refcount and mapcount of the current > > page. > > > This memory can be moved during kernel compaction. At this time, > > refcount > > > is less than or equal to mapcount. > > > After this memory is kcompacted and placed in the cma buffer, > > under > > > certain special conditions, the refcount may be greater than the > > mapcount > > > (ex:the current page is being used by fs), and then migrate will > > fail. > > > > But that's always true. Any page that is currently in use might have > > its refcount temporarily incremented. There's nothing special about > > pages that belong to a file. You've basically just prevented all > > filesystem memory from being migrated to the CMA area, and that's > > wrong. > > > Yes, we agree with you that refcount may temporarily incremented. > Issues we have reproduced: > The current page is migrated to the cma area by kcompactd, rather than > allocated by kernel memory allocater. > Our opinion is that if a page cannot be allocated to the CMA area, then > we should not put it in the CMA area when doing kernel migration. This > seems more reasonable. Do you agree with this view or do you have any > other suggestions? That does seem reasonable. But I don't know if it helps you at all; is there a type of allocation which is migratable but not allocatable from the CMA area? > > What's special about this page? Or were you just unlucky? > We didn't find anything special about this page. During our debugging, > we found that once a similar problem occurs in the current page, it can > no longer be migrated (retrying after an hour will not work). Perhaps you can find out more information about this particular page; who allocated it, why was it migratable initially but not the second time? Perhaps something happens to this page to keep the refcount high, and if we can find out that will happen, we can migrate it out of the CMA area before incrementing the refcount.