From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 DC45D1E1C3A for ; Fri, 10 Jan 2025 02:30:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736476207; cv=none; b=o9n+y261F6ZYQJEUkBRf8VhfwR38Amn8NZbBbaskOKsaEegRQ9mnkZ5DC9knPE/1P4Sa4L3uFG3aCOGxM9VQtthb2JDKDlsdfEWRNzEYzn1YRoXvH7QZxm9BqPhH+zgpLCOvmEhwLYclCf4sQ7x9ReKntIt7y2dj5sYvDeoqSgo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736476207; c=relaxed/simple; bh=L2wvkIVPv/r2SV/07ShdidkADiM+2npi2lUC0CBgN4g=; h=Subject:To:References:CC:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=dqcC1ldZrMhzlZA6UMIZat53dFzz4f2DNd0KhzonW/qgKVQsyzNrCc5FoWjs7QNKX8mNSZwjF8R5a+7hNBf88rP57cMy9zX1g2eNWon1oQb/U1D+y5Hq8XiXAcQ4pcBp/stipeo1fk8Vkeo71utkW3OETWIc8/Sr7diHJGrSoyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YTlsc22mSz11SGK; Fri, 10 Jan 2025 10:27:00 +0800 (CST) Received: from kwepemg200013.china.huawei.com (unknown [7.202.181.64]) by mail.maildlp.com (Postfix) with ESMTPS id D5946140380; Fri, 10 Jan 2025 10:29:56 +0800 (CST) Received: from [10.174.179.24] (10.174.179.24) by kwepemg200013.china.huawei.com (7.202.181.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 10 Jan 2025 10:29:55 +0800 Subject: Re: [PATCH] mm: khugepaged: fix call hpage_collapse_scan_file() for anonymous vma To: Matthew Wilcox References: <20250109070059.369257-1-liushixin2@huawei.com> CC: Andrew Morton , Chengming Zhou , Kefeng Wang , Nanyong Sun , Muchun Song , Qi Zheng , Johannes Weiner , Yang Shi , , From: Liu Shixin Message-ID: <88b0740c-d038-0f4e-2a4b-792cb5b6cd8c@huawei.com> Date: Fri, 10 Jan 2025 10:29:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemg200013.china.huawei.com (7.202.181.64) On 2025/1/9 21:40, Matthew Wilcox wrote: > On Thu, Jan 09, 2025 at 03:00:59PM +0800, Liu Shixin wrote: >> Add vma_is_anonymous() check to make such vma be processed by >> hpage_collapse_scan_pmd(). > Wouldn't it be better to replace the vm_file check with > vma_is_anonymous()? ie: > >> - if (IS_ENABLED(CONFIG_SHMEM) && vma->vm_file) { >> + if (IS_ENABLED(CONFIG_SHMEM) && vma->vm_file && >> + !vma_is_anonymous(vma)) { > + if (IS_ENABLED(CONFIG_SHMEM) && > + !vma_is_anonymous(vma)) { > > > . > Thanks, replace is better. Yang Shi suggest me to set vm_file to NULL when mmap /dev/zero as private. It seems only /dev/zero is special which has vm_file but no vm_ops. This way may solve more hidden similar problems, so I prefer it now.