Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp565024rwd; Thu, 25 May 2023 00:13:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6K4NcOwePKFTsPgxwOjOg5IJX693r6+6zgbMLK4/yGKabc3CY2nDUo/iO/DxEGtE/AEPk3 X-Received: by 2002:a05:6a00:2305:b0:63b:4313:f8c4 with SMTP id h5-20020a056a00230500b0063b4313f8c4mr7366052pfh.9.1684998793280; Thu, 25 May 2023 00:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684998793; cv=none; d=google.com; s=arc-20160816; b=agJkeUL+0FY3+X9qCGWxWgvq2XKesO7vZn71kqPeKFFK878F6E3avlm2JVwY6ztoDE mcnGxC1C0LOLYEfbzfBFPoaUwTDcSK8kY5jj5eEr1zh/W1fpIMq0CGk7/z2IuFcALnV6 e1Lpi9fWtlZIUJY0RkqTKxfb2j0FHIxxrUEIoTi7lHpIdI/NdjoZItDMO1UlZCtsVNRp 27qkFzbIGkrlZOj9HkPSep0/S29Sf12LK2KTbPp63zK42k34KF7A+ZhIyl93cMOB4Owr IVmTs5iT1wzuepMWVKnk/MHNY5TozeIojcseUxdD7wKroqYCrlMAuRx0akuTv7MUudQg 4C3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=jjUmWgHbPa0c6WlFbJhIW7f3eEgjAePh7ij8b/Ha5ac=; b=YpNa+BQna3s+WudvH3rUsm8CEqQVCMw7/2mSNmf+kYduG6d/FWgPpUDSq9jga0bhMI yG/PEs4lMlAPHFGMfIkaKZUnYxf2CJixEv5ksQLGy9VEL6uMQsHrvoDB40mwr/SitK/T sRU6FGjaKa7ONxwSi14MrxYS7IdzzFowVm7k6CQyLf8rOotYuJZe0ayFSicWeZcYjuwn 51NmC+DZgRFFluEew9WrZeMPnL3JYg89BwU7O8r54l7+t926ETOjzcI77hBb/YSxQsjq wr5S8fgRK10h6q6WtOGZ5STypT9pTh0hZGrp2JDlS3BlJZVGUKkrBKB7cqlVHi0bU09f AMgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020aa79503000000b0063b68fa0807si832564pfp.263.2023.05.25.00.13.00; Thu, 25 May 2023 00:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235561AbjEYHAM (ORCPT + 99 others); Thu, 25 May 2023 03:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233760AbjEYHAL (ORCPT ); Thu, 25 May 2023 03:00:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E48EE46 for ; Thu, 25 May 2023 00:00:09 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EEFAF1042; Thu, 25 May 2023 00:00:53 -0700 (PDT) Received: from [10.162.43.6] (unknown [10.162.43.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1DB363F762; Thu, 25 May 2023 00:00:06 -0700 (PDT) Message-ID: <0b136cc3-c85e-1183-5ddc-ab99fd58c012@arm.com> Date: Thu, 25 May 2023 12:30:04 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] arm64: mm: pass original fault address to handle_mm_fault() in PER_VMA_LOCK block Content-Language: en-US To: Jisheng Zhang , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20230524131238.2791-1-jszhang@kernel.org> From: Anshuman Khandual In-Reply-To: <20230524131238.2791-1-jszhang@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/24/23 18:42, Jisheng Zhang wrote: > When reading the arm64's PER_VMA_LOCK support code, I found a bit > difference between arm64 and other arch when calling handle_mm_fault() > during VMA lock-based page fault handling: the fault address is masked > before passing to handle_mm_fault(). This is also different from the > usage in mmap_lock-based handling. I think we need to pass the > original fault address to handle_mm_fault() as we did in > commit 84c5e23edecd ("arm64: mm: Pass original fault address to > handle_mm_fault()"). > > If we go through the code path further, we can find that the "masked" > fault address can cause mismatched fault address between perf sw > major/minor page fault sw event and perf page fault sw event: > > do_page_fault > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, ..., addr) // orig addr > handle_mm_fault > mm_account_fault > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, ...) // masked addr > > Fixes: cd7f176aea5f ("arm64/mm: try VMA lock-based page fault handling first") > Signed-off-by: Jisheng Zhang LGTM Reviewed-by: Anshuman Khandual > --- > arch/arm64/mm/fault.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > index cb21ccd7940d..6045a5117ac1 100644 > --- a/arch/arm64/mm/fault.c > +++ b/arch/arm64/mm/fault.c > @@ -600,8 +600,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, > vma_end_read(vma); > goto lock_mmap; > } > - fault = handle_mm_fault(vma, addr & PAGE_MASK, > - mm_flags | FAULT_FLAG_VMA_LOCK, regs); > + fault = handle_mm_fault(vma, addr, mm_flags | FAULT_FLAG_VMA_LOCK, regs); > vma_end_read(vma); > > if (!(fault & VM_FAULT_RETRY)) {