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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3207EC7EE26 for ; Mon, 22 May 2023 08:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231620AbjEVI3P (ORCPT ); Mon, 22 May 2023 04:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbjEVI3F (ORCPT ); Mon, 22 May 2023 04:29:05 -0400 Received: from out-6.mta1.migadu.com (out-6.mta1.migadu.com [95.215.58.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CAE8BA for ; Mon, 22 May 2023 01:29:03 -0700 (PDT) Message-ID: <05ab340a-d500-e742-fd59-5ef2e4ea86e0@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684744141; h=from:from: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=2LMykAnh9K8a8DhpkmHVAinUJdctqspZeCJeDVlxCjc=; b=LqXBFS6Cdr/XbW6ug56FJwR2eJFwuNCWNp5foT7HIBJKb2gQRgBGOKwQAdOh32ZBXXSQv0 vo8DmU35b+7B9+Nsmvy16xlVLawLnSci+BhiRonXdG/h04WSXqSZ/IRYkIXWPE95y5vHQq zYJwMe3Uxz+cBNLhjMSy/psfVn5pTe4= Date: Mon, 22 May 2023 16:28:54 +0800 MIME-Version: 1.0 Subject: Re: [PATCH] mmu_notifiers: Notify on pte permission upgrades Content-Language: en-US To: Alistair Popple Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, will@kernel.org, nicolinc@nvidia.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, jgg@nvidia.com, John Hubbard , Andrew Morton References: <20230522063725.284686-1-apopple@nvidia.com> <620eef7f-ee01-673c-b097-243d6fe25b09@linux.dev> <87a5xwajn4.fsf@nvidia.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: <87a5xwajn4.fsf@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/22 15:45, Alistair Popple wrote: > > Qi Zheng writes: > >> Hi Alistair, >> >> On 2023/5/22 14:37, Alistair Popple wrote: > > [...] > >>> + if (changed) { >>> + struct mmu_notifier_range range; >>> + >>> + mmu_notifier_range_init(&range, MMU_NOTIFY_PROTECTION_UPGRADE, >>> + 0, vmf->vma, vmf->vma->vm_mm, >>> + vmf->address & PAGE_MASK, >>> + (vmf->address & PAGE_MASK) + PAGE_SIZE); >>> + mmu_notifier_invalidate_range_start(&range); >>> + mmu_notifier_invalidate_range_end(&range); >>> + } >> >> There are four similar patterns, can we introduce a helper function to >> deduplicate them? > > For sure. How about something like this? > > void mmu_notifier_range_start_end(enum mmu_notifier_event event, > struct vm_area_struct *vma, > struct mm_struct *mm, > unsigned long start, > unsigned long end) LGTM. :) > > As an aside I didn't just use mmu_notifier_invalidate_range() as that > doesn't allow an event type to be set for interval notifiers which may > want to filter this. > >>> + >>> return 0; >>> } >>> > -- Thanks, Qi