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 X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB995C433DF for ; Mon, 12 Oct 2020 12:54:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8B1B521BE5 for ; Mon, 12 Oct 2020 12:54:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KIsdUJoE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B1B521BE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 37CA894000A; Mon, 12 Oct 2020 08:54:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0818994000D; Mon, 12 Oct 2020 08:54:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E89D994000A; Mon, 12 Oct 2020 08:54:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id AD66B94000C for ; Mon, 12 Oct 2020 08:54:34 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 45668181AE864 for ; Mon, 12 Oct 2020 12:54:34 +0000 (UTC) X-FDA: 77363267268.12.sheet06_450cf83271fa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 1E3DB1800F751 for ; Mon, 12 Oct 2020 12:54:34 +0000 (UTC) X-HE-Tag: sheet06_450cf83271fa X-Filterd-Recvd-Size: 3839 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Mon, 12 Oct 2020 12:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602507273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQDWeH2qYFqH9wAdtLA1r7drvKX0EXkimbPBAYSfLvU=; b=KIsdUJoE29a0A2voKF2vWkMofS4DCAfkLpVJUTIts6EhVDrJQXiH1o+6y2PCONr3353BPa BFJBO2Kzytt/QG8EHxIbXeEPTwcDvdietBjHwhk2ePvFnIq7HRvy81+NzvFhEEy7Lmd6IL XqB6HxdgftZLHw0dsFD0SZK1kQempc4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-83-aCYmZaVGOvSMCy6HIaBuKw-1; Mon, 12 Oct 2020 08:54:31 -0400 X-MC-Unique: aCYmZaVGOvSMCy6HIaBuKw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B2DF1084D60; Mon, 12 Oct 2020 12:54:30 +0000 (UTC) Received: from t480s.redhat.com (ovpn-113-251.ams2.redhat.com [10.36.113.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7957260C07; Mon, 12 Oct 2020 12:54:28 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , David Hildenbrand , Jason Wang , Pankaj Gupta Subject: [PATCH v1 06/29] virtio-mem: generalize virtio_mem_owned_mb() Date: Mon, 12 Oct 2020 14:53:00 +0200 Message-Id: <20201012125323.17509-7-david@redhat.com> In-Reply-To: <20201012125323.17509-1-david@redhat.com> References: <20201012125323.17509-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable 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: Avoid using memory block ids. Rename it to virtio_mem_contains_range(). Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Pankaj Gupta Signed-off-by: David Hildenbrand --- drivers/virtio/virtio_mem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 6bbd1cfd10d3..821143db14fe 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -500,12 +500,13 @@ static bool virtio_mem_overlaps_range(struct virtio= _mem *vm, } =20 /* - * Test if a virtio-mem device owns a memory block. Can be called from + * Test if a virtio-mem device contains a given range. Can be called fro= m * (notifier) callbacks lockless. */ -static bool virtio_mem_owned_mb(struct virtio_mem *vm, unsigned long mb_= id) +static bool virtio_mem_contains_range(struct virtio_mem *vm, uint64_t st= art, + uint64_t size) { - return mb_id >=3D vm->first_mb_id && mb_id <=3D vm->last_mb_id; + return start >=3D vm->addr && start + size <=3D vm->addr + vm->region_s= ize; } =20 static int virtio_mem_notify_going_online(struct virtio_mem *vm, @@ -800,7 +801,7 @@ static void virtio_mem_online_page_cb(struct page *pa= ge, unsigned int order) */ rcu_read_lock(); list_for_each_entry_rcu(vm, &virtio_mem_devices, next) { - if (!virtio_mem_owned_mb(vm, mb_id)) + if (!virtio_mem_contains_range(vm, addr, PFN_PHYS(1 << order))) continue; =20 sb_id =3D virtio_mem_phys_to_sb_id(vm, addr); --=20 2.26.2