Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp336720rdb; Sat, 27 Jan 2024 08:27:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHd+0dycTY8WJ/tRbyctypn66aHs+4sEogEpmUawLeM3Dd169ZPijsI2LwosOt+iNV53FbU X-Received: by 2002:a05:6359:6196:b0:175:8e89:6f47 with SMTP id sb22-20020a056359619600b001758e896f47mr739908rwb.45.1706372841714; Sat, 27 Jan 2024 08:27:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706372841; cv=pass; d=google.com; s=arc-20160816; b=VziDWCx+u2Q76Es24VrHo/2o7I+bwAMRBax0K7BZA2b0ihi3EnlWPZp617IjNjSeO1 GkqLiC4bDpQ3+XFkd28A7/oiNgprH2hG+s6SiyhqFB9MzoTM5zN9+U6DFmzNvy6MuTkT gL+sgPIrPez+jHMb1/N39A67DL/wc5e5oSLVnm3v0QNG6JyblXHku+pVLglaEJabrdfS hj/TnicWDPJy0AFUGawOgYFD5pZzyA4V5eXG5ik9g6hiICp/H4790b2JxYT+JQog3V4Y VU12VvRtBfDRtWAY30+nsVbMmu9b4wK/HC9Aqqo0k3gVlVWVBVw4Y6oISRGDLrXMgk4z USeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5MZNQZ+U0qN5MQqp/SbJWOMILdkVqVbvXC98OckCEaY=; fh=CBgMHhnXG4aTQahicjRVED0vM6mowVT9t/RFwMuQ7/4=; b=lhGyWKjBZ4xgHuuyM1E3ZarMlin8jzNuCO90Y2ub91RtfyncsJppM9kKycHjQ4/6Su OGEQZrI6AeetYgdpGrLuUYU6SX/Lr6sA6bKxm3fQWNy2+U8nvD1Il6QiOjmhRQ/EfwKV XJs0hFjg7RD9LscmvoDjgEBbG128GIRgqRwq993SJeNKmOs6X88e5xy2D6H8cvf+29ZV j2nMnFy35gwrv5TCHFOcGvMylwJI3/oW3u6Oxo5z9Jgx7GRyktWGqMdvCzUz4O5I2ECt tThMS7AVt7vcK491P7wDH2mdHn1sWecA2tjtJNu0XVxucxFp81iPsd92aXHPZLlOYail 51Nw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=rqYs4I7p; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-41304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41304-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k13-20020a05620a414d00b00783a28462cdsi4235681qko.569.2024.01.27.08.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:27:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=rqYs4I7p; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-41304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41304-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 603CE1C220D1 for ; Sat, 27 Jan 2024 16:27:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76E7B2D602; Sat, 27 Jan 2024 16:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rqYs4I7p" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C3492D603 for ; Sat, 27 Jan 2024 16:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372586; cv=none; b=OgVuF23X4J8CkovxBVG21epvgijCRCbA/BG3672dNsqDgGi/7eGxJB4ojDHjrur9Me2WYOmWIC4v+eXXL+enhqOHZ2Wv1wGzE3bkyKogae992QBEo94brk6CcF0yqvZTXG90GomZ8PjNogOeVHxHD0neii59xyCRNzzl+ob03gA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372586; c=relaxed/simple; bh=gg08MmGis9WStArL4LZ902VV0ssnodUvEEpCAPG85SQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X08jBL0WeyXmJz8j+KenCoMKYeOIPi8YcYmnKkY0Ar45JxrTAG09ImX+xLyBvsT9YGCjC4aH1upKYaFZsUiwaBdXtEEEVyBh9oJDU4u65y7zIhyR/cX5uMPAiKX9ds/ZNu/GtQPBFALwVygKttO4LaTiWJyywbltpvclQ/IUtL0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=rqYs4I7p; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> 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.