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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67B1DC77B75 for ; Mon, 22 May 2023 08:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zs0OmQvkCkk71Xg0c1Ir5RT6LbiySTBaAoGaqhRYWfM=; b=I0NrE/O8hbxsra /bltNWbLBhULlndQXqIdv6x+xa07b7fWQNuYSBBLbkhQ4e15pkpD4injIKZ+qX+wAJ5WYkDDfG8Jl DiCU7XniwHJH4nhbHuJSF8DPITE3HPuzDyxjk7er5Wpy8uvH2a9LGB51oUe0a7cv7e7e/GBQzdyCj UtrA9SUeQQKM5V/Qei0RI81o3sCRR42Yii1NDGZtAngQtpOzOWSW4GfncWhJ5if/TZEzsUuezDbGg /dfvRlZNYU97fAjZD2584FXClT+O6s6Zhcc+Vg3f3/ptbZKiPLVZYzSgn+BQOEWxoX5uEqU8ty7Te jYmP1H/e5j86M5doMq7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q10ui-005kYz-39; Mon, 22 May 2023 08:29:08 +0000 Received: from out-35.mta1.migadu.com ([2001:41d0:203:375::23]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q10ue-005kXA-1V for linux-arm-kernel@lists.infradead.org; Mon, 22 May 2023 08:29:06 +0000 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> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230522_012904_923764_87FBDFAD X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel