Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp95615rdb; Sun, 21 Jan 2024 19:31:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwItd9cMcdDJ3BLlrfDFEyLxcFKY6JLQ+oKVrPKerj6d7c5vx9KsHewTdlFdKGKvt0WtNb X-Received: by 2002:a17:903:185:b0:1d5:f0da:625a with SMTP id z5-20020a170903018500b001d5f0da625amr4762495plg.7.1705894285453; Sun, 21 Jan 2024 19:31:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705894285; cv=pass; d=google.com; s=arc-20160816; b=jPC/41vE4oA3fpNFLQfiBTSGbjWvESbjzkMrqMafMT4Xd5BPG7HJgSIABDeltzW2Vl JjHDlrQdWz7MxtxiKN/evrNWW1mM/JUo8tbSDbHm/N2LtS1GTDMxYAI+DrAMMAM3+cuK CjTIQrssjFymgc80jNZl6DdxzMzGk1LqqbdZcn3sZOZ+UU301gGmctkJhN3w+KPVcR/u MQ5EOC4ysxLWyc88ARQu5/TsrEGQi8BEL8rfyjC8im9yXx1NeQKuoSmfU4N2cLXRPWna JtkJDgBhifKNkDeYDK3pYxEiSSSJPo2ULbCUWLw6uGQicznOpZTaGegMMBFk3P2mZSWP nMaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=OtF+0AZ9mYZSgEmOfYMUgTrNZfxIctdI17hPwZH8CYw=; fh=XppNyWMNc04xvTm+hf2ayH2XHzIAd9ZFEVs/kXoKWPU=; b=RGYpyfCA/Wre12g9UxR1MQDz61vlYTTz7hidbPsFpFKjkaCDp/WUNUsOOp+BYm6+x+ Lyk0XBhVbJOb6MXnLe+1qlWrX56RppmnS5uFVwzkhctA/73Kb7S12lY7w0ya/tqo7VZ7 LTNM6Bn5Tf8GuRpjmfkI77AWQyEvYOAdPKtugtYb2wMmViqpNyByQEzjUJU2b5JBdGi0 w2dIi2pJ4x06R+EVNfEyx2ur81DeLLCrvZYtV23rbdYebAvaKM5CkyhGFsRk2RWPUc2x IDYbFvh36Q8O83WZ0zXZrXj3Wc3Eqyx5G6AaNi/cPiG3HZjiBPMIQPOTvqOTeNXLgHlG Ul1w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="blbufh+/"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-32301-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32301-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y9-20020a17090322c900b001d5f3875154si7386860plg.319.2024.01.21.19.31.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 19:31:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32301-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="blbufh+/"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-32301-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32301-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 16422282F65 for ; Mon, 22 Jan 2024 03:31:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93205184F; Mon, 22 Jan 2024 03:31:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="blbufh+/" 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 F2B2315CB for ; Mon, 22 Jan 2024 03:31:15 +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=1705894277; cv=none; b=qzFQQxE8KeHvkqU2IIwTCel45o3EA2SjUz3eJMQ1ETRo1mxhATaECop03iX64NH8uRLTyTu4Q5VjUi4WUUx7uk3UJvTI/fKkFxJWj4OLrhnUlXYc2rmBHw3ma0oo7iOoyfnfsI+czZn+/7TUWqHqh4ycczM9q1wgi1sXYlimB3A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705894277; c=relaxed/simple; bh=JoBhClsR8dGt3/RIIrvVBN09xaObMskQ2Xlc9afLWGk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=keAOIhKluDj+1pBW38ykI9PC485hh0ruc1BXc7WPDOu30sAbg27R69MazfcuBqj0kkzhXXAA3xcLbIkiAbWSzA/samIfAqVxrlzhlyJHec9zelc/Cde+sIJRhisllwJ4CeALvi2JHv0HnC3MvZB6jSFsY1NYl/xjVaXUfePaBWQ= 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=blbufh+/; 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-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OtF+0AZ9mYZSgEmOfYMUgTrNZfxIctdI17hPwZH8CYw=; b=blbufh+/edoEOsvCjfxyMSkPeL Ft4p4rX0rJGFWaJVaa1dcGE4froQC4i7GaHj8d/XbKoIaWqQ3s6PFM3/gLxFmAC/EktiTkg8kcZ3S /4D7I7qXQAaGuEHuQBd0Bi2RgO5kDRlTIlnZLN9WRpZ4zOvrg5t07ogw2aCn4L/URAC/Cr4rPw140 LKVzTw561LO0alHSJIwtlmftXXXXQK3DGrseqfkS689bO2EfmSIh45UCeIty/TV1R41Ky8fFFYKey p1Mh3fp3l4lJG8I29Z+5mp88NQzTbFBKjgSen8VLMPdoBeZ0k36TJ1a2na0hzbnRwH16sXxgzyKId jGxSyZcg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rRl1j-0000000Eqh2-1y9B; Mon, 22 Jan 2024 03:31:11 +0000 Date: Mon, 22 Jan 2024 03:31:11 +0000 From: Matthew Wilcox To: Haiqiang Gong Cc: linux-kernel@vger.kernel.org, mike.zhang@mediatek.com, Andrew Morton , Matthias Brugger , AngeloGioacchino Del Regno , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] mm/compaction: add check mechanism to avoid cma alloc fail Message-ID: References: <20240122022317.30091-1-Haiqiang.Gong@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=us-ascii Content-Disposition: inline In-Reply-To: <20240122022317.30091-1-Haiqiang.Gong@mediatek.com> On Mon, Jan 22, 2024 at 10:23:17AM +0800, Haiqiang Gong wrote: > cma alloc may fail when we doing cma alloc/free test on kernel 5.10/5.15. > > We found that the next memory cannot be migrated because of the alloc of > fs as next backtrace: > __alloc_pages_nodemask > pagecache_get_page > grow_dev_page > __getblk_gfp > ext4_sb_breadahead_unmovable > __ext4_get_inode_loc > __ext4_iget > ext4_lookup > __lookup_slow > walk_component > path_lookupat > filename_lookup > vfs_statx > This kind of unmovable memory is not placed in the cma buffer when kernel > memory alloc but is migrated in by kcompactd when the kernel migration. > It will cause memory can't be migrate when cma alloc. 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? > Add check mechanism in the compaction_alloc() where kcompaced alloc for > memory. Will return NULL and give up this memory migration if the > allocated memory is in the cma buffer and the memory is unmovable. > +static bool forbid_move_to_cma_range(struct folio *src, struct folio *dst) > +{ > + if (folio_mapping(src) && is_in_cma_range(dst)) > + return true; > + > + return false; > +} Why would folio_mapping() be the right way to determine if memory is unmovable? The vast majority of filesystem data is movable.