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 DE1FAC43334 for ; Sat, 18 Jun 2022 04:17:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9A1F6B0071; Sat, 18 Jun 2022 00:17:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4BC56B0072; Sat, 18 Jun 2022 00:17:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D11836B0073; Sat, 18 Jun 2022 00:17:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BF6266B0071 for ; Sat, 18 Jun 2022 00:17:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5C0056179B for ; Sat, 18 Jun 2022 04:17:40 +0000 (UTC) X-FDA: 79590047880.14.A195F67 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf31.hostedemail.com (Postfix) with ESMTP id 0766520009 for ; Sat, 18 Jun 2022 04:17:37 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VGi26k0_1655525852; Received: from 30.13.184.185(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VGi26k0_1655525852) by smtp.aliyun-inc.com; Sat, 18 Jun 2022 12:17:33 +0800 Message-ID: <73715d55-288a-beb0-bb98-210a9233d25a@linux.alibaba.com> Date: Sat, 18 Jun 2022 12:17:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] arm64/hugetlb: Simplify the huge_ptep_set_access_flags() To: Catalin Marinas Cc: will@kernel.org, mike.kravetz@oracle.com, songmuchun@bytedance.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655525860; 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; bh=iS1+xWvqE53UeR7fUUZ86gS02PEMdC5FKv5QdopH9dU=; b=WfO8eL7b6zdXVQgBb3xuf9BkB8NQ/ALCPpt3IZNktiPbILqMaTv69uUOk+9M4EjfaHfLEb fnk8eJ41N6DcsKiEvAhSkxmn9pRfI0JGdrXFZ79OGzy+pWhd4LUNPFFrFJwBXkp1oJFXnG 26KlH0eVRHUql5oTC8FIp9YFwqGSEQY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655525860; a=rsa-sha256; cv=none; b=W9UQ150FAay61Q+d6SuvoCARn14+SmMAvorXAqoDHNStGKf3gPcFyUh9/9WUBLpz0yTqb2 lhO4rztZrxfZLg1ZMeTGTjo5ibx6s+Rj1B79owJKdC21J15yQuKC4duCwU7+uGXrUd17fr xV3GfH0HNgSG9XcZDGB7LJG8XgfMr/U= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf31.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Stat-Signature: 9ry1ngytspug83w7ocg7r1mko3d88n1b X-Rspamd-Queue-Id: 0766520009 Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf31.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Rspamd-Server: rspam01 X-Rspam-User: X-HE-Tag: 1655525857-426320 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 6/18/2022 1:46 AM, Catalin Marinas wrote: > On Wed, May 25, 2022 at 06:31:09PM +0800, Baolin Wang wrote: >> After commit bc5dfb4fd7bd ("arm64/hugetlb: Implement arm64 specific >> huge_ptep_get()"), the arm64 specific huge_ptep_get() will always >> consider the subpages' dirty and young state for CONT-PTE/PMD hugetlb, >> so there is no need to check them again when setting the access flags >> for CONT-PTE/PMD hugetlb in huge_ptep_set_access_flags(). >> >> Meanwhile this also fixes an issue when users want to make the CONT-PTE/PMD >> hugetlb's pte entry old, which will be failed to make the pte entry old >> since the original code will always consider the subpages' young state >> if the subpages' young state is set. For example, we will make the >> CONT-PTE/PMD hugetlb pte entry old in DAMON to monitoring the accesses, >> but we'll failed to monitoring the actual accesses of the CONT-PTE/PMD >> hugetlb page, due to we can not make its pte old. >> >> Thus remove the code considering the subpages' dirty and young state in >> huge_ptep_set_access_flags() to fix this issue and simplify the function. > > The ptep_set_access_flags() semantics (non-huge) never clear the access > flag, so mkold is not allowed. I think damon_hugetlb_mkold() is wrong in > assuming that huge_ptep_set_access_flags() allows a young->old huge pte > transition. After reading the code carefully, yes, you are right. Seems I need change to use set_huge_pte_at() to make the huge pte old. Thanks. By the way, after changing to use set_huge_pte_at() in the damon_hugetlb_mkold(), it seems to me that we still do not need to get the subpages' dirty and young state again in huge_ptep_set_access_flags(). How do you think?