Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3976830pxu; Mon, 12 Oct 2020 06:28:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrNdr3LtjlNgv91qpygScoeeKNlnP+YJ/SW+6ebAizYEG3Hp4B9j5iM1A0NMX+tglZArsk X-Received: by 2002:aa7:c5c4:: with SMTP id h4mr14531920eds.379.1602509302291; Mon, 12 Oct 2020 06:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602509302; cv=none; d=google.com; s=arc-20160816; b=SVaQf2AZ4glizpgErxqvnociTf6fVcJ9idiHrOhlCh86oHDhJL+1l3hLTFtO+4x249 vW3hzEP/4+stK4BAJabtOvEi0lPX+mmES+6z1MyimU9Z9iy1e1AhoQuaL5tpDa129jbu hDp7lf9kEmCMv+s+Tdv3C7kE4tBPgSRzdH2B6mV3FvshXNNKZ6mO2UEUZvdeuWoRFjY0 DcLeuNy2SNYp0dMTlp9MKqFsysNrgSMReDns7JaLsoQfIGkD/Mf7VwQaXOG9zhCOq738 y1nUNWxvt5GAWs/tx04Sh10uCBtB3B8io5GzN/VBX3LZzsyos+p5v8S7KSdZSuwc2J+n VDpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sQDWeH2qYFqH9wAdtLA1r7drvKX0EXkimbPBAYSfLvU=; b=U0o7xt6sLnkmwstx+DxNFEyhC3yYj81O9WdQJmP2YINOS9RGcaOxYTUA3vueD8Vf2R idkKOq0lVBOf09nm6e4LnylwGjgrfDKBpha94i88PVBhre3Bc94opQshGFNcZ8TWWfl1 MgwJYK4PDSQ3fmWpRGmgviPwSyksets7/5eTKzi28m6/U6BP0F54QKdv7+nQXzsoA6Si DYgUSEIzwukDOgR7byr/AEYKzYler8K7ZhIbgugg+EB/15hU7jQdTWuJzAn3c7SL1SMi h0beNFtBxtYj30GNo9YyZflUWpG877VWSkrnY2zdIjiHvdJ3ErOMTrJY/OP2I2SGsFGe CD/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KIsdUJoE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bl4si14418812ejb.190.2020.10.12.06.27.58; Mon, 12 Oct 2020 06:28:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KIsdUJoE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730046AbgJLMyj (ORCPT + 99 others); Mon, 12 Oct 2020 08:54:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24533 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbgJLMye (ORCPT ); Mon, 12 Oct 2020 08:54:34 -0400 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, } /* - * 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 from * (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 start, + uint64_t size) { - return mb_id >= vm->first_mb_id && mb_id <= vm->last_mb_id; + return start >= vm->addr && start + size <= vm->addr + vm->region_size; } static int virtio_mem_notify_going_online(struct virtio_mem *vm, @@ -800,7 +801,7 @@ static void virtio_mem_online_page_cb(struct page *page, 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; sb_id = virtio_mem_phys_to_sb_id(vm, addr); -- 2.26.2