From nobody Sun Feb 8 17:21:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568229082; cv=none; d=zoho.com; s=zohoarc; b=mwPVhawxY3s7fi/NJr9lnGTF1OU2Cibn2fOBBuLlbEc7BZyu2BK7MqaGYKhprwrE79K4D/urkOcXFvDv8eUOYEsEbFtw8zO3rqbhcuQ+29AFnPcOJEfG1s1s9bIU4Z61pFUKlQng6QKN4Al+g7KSiD4Woam8NZi5BwMV9jOQRoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568229082; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=m8/f5kIjQnoEpuUrCun79CnAmE2cDa0yf7sY3eVEvL0=; b=hXXKRQEeum/nQU3QAya1S56SKpz7D14ze/8kwnDkl3Ht3cCEsdO3kYRb8DDI6qT5wcpSmv5htXM0l72vI+SNFcWInSYzT3H6PC+36h4V6c6UHiprHiEvU+5lJyrsSmU+T9kOJ2/IEZo8fVPTnFiRJvszct+IXB8qK7wz5oM1NFo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568229082178685.9434328193199; Wed, 11 Sep 2019 12:11:22 -0700 (PDT) Received: from localhost ([::1]:55666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i881R-0000Hq-3w for importer@patchew.org; Wed, 11 Sep 2019 15:11:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54091) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i87wk-0003yy-Pq for qemu-devel@nongnu.org; Wed, 11 Sep 2019 15:06:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i87wj-0006bH-Kz for qemu-devel@nongnu.org; Wed, 11 Sep 2019 15:06:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i87wj-0006an-C9 for qemu-devel@nongnu.org; Wed, 11 Sep 2019 15:06:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3A015AFE3 for ; Wed, 11 Sep 2019 19:06:28 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-243.ams2.redhat.com [10.36.117.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 874F860167; Wed, 11 Sep 2019 19:06:27 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, pbonzini@redhat.com, ehabkost@redhat.com, berrange@redhat.com, quintela@redhat.com Date: Wed, 11 Sep 2019 20:06:19 +0100 Message-Id: <20190911190622.7629-3-dgilbert@redhat.com> In-Reply-To: <20190911190622.7629-1-dgilbert@redhat.com> References: <20190911190622.7629-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 11 Sep 2019 19:06:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/5] migration: Use automatic rcu_read unlock in ram.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Use the automatic read unlocker in migration/ram.c; only for the cases where the unlock is at the end of the function. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/ram.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b2bd618a89..1bb82acfe0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -181,14 +181,14 @@ int foreach_not_ignored_block(RAMBlockIterFunc func, = void *opaque) RAMBlock *block; int ret =3D 0; =20 - rcu_read_lock(); + RCU_READ_LOCK_AUTO; + RAMBLOCK_FOREACH_NOT_IGNORED(block) { ret =3D func(block, opaque); if (ret) { break; } } - rcu_read_unlock(); return ret; } =20 @@ -2398,13 +2398,12 @@ static void migration_page_queue_free(RAMState *rs) /* This queue generally should be empty - but in the case of a failed * migration might have some droppings in. */ - rcu_read_lock(); + RCU_READ_LOCK_AUTO; QSIMPLEQ_FOREACH_SAFE(mspr, &rs->src_page_requests, next_req, next_msp= r) { memory_region_unref(mspr->rb->mr); QSIMPLEQ_REMOVE_HEAD(&rs->src_page_requests, next_req); g_free(mspr); } - rcu_read_unlock(); } =20 /** @@ -2425,7 +2424,8 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) RAMState *rs =3D ram_state; =20 ram_counters.postcopy_requests++; - rcu_read_lock(); + RCU_READ_LOCK_AUTO; + if (!rbname) { /* Reuse last RAMBlock */ ramblock =3D rs->last_req_rb; @@ -2467,12 +2467,10 @@ int ram_save_queue_pages(const char *rbname, ram_ad= dr_t start, ram_addr_t len) QSIMPLEQ_INSERT_TAIL(&rs->src_page_requests, new_entry, next_req); migration_make_urgent_request(); qemu_mutex_unlock(&rs->src_page_req_mutex); - rcu_read_unlock(); =20 return 0; =20 err: - rcu_read_unlock(); return -1; } =20 @@ -2712,7 +2710,8 @@ static uint64_t ram_bytes_total_common(bool count_ign= ored) RAMBlock *block; uint64_t total =3D 0; =20 - rcu_read_lock(); + RCU_READ_LOCK_AUTO; + if (count_ignored) { RAMBLOCK_FOREACH_MIGRATABLE(block) { total +=3D block->used_length; @@ -2722,7 +2721,6 @@ static uint64_t ram_bytes_total_common(bool count_ign= ored) total +=3D block->used_length; } } - rcu_read_unlock(); return total; } =20 @@ -3086,7 +3084,7 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) RAMBlock *block; int ret; =20 - rcu_read_lock(); + RCU_READ_LOCK_AUTO; =20 /* This should be our last sync, the src is now paused */ migration_bitmap_sync(rs); @@ -3107,13 +3105,11 @@ int ram_postcopy_send_discard_bitmap(MigrationState= *ms) * point. */ error_report("migration ram resized during precopy phase"); - rcu_read_unlock(); return -EINVAL; } /* Deal with TPS !=3D HPS and huge pages */ ret =3D postcopy_chunk_hostpages(ms, block); if (ret) { - rcu_read_unlock(); return ret; } =20 @@ -3128,7 +3124,6 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) trace_ram_postcopy_send_discard_bitmap(); =20 ret =3D postcopy_each_ram_send_discard(ms); - rcu_read_unlock(); =20 return ret; } @@ -3149,7 +3144,7 @@ int ram_discard_range(const char *rbname, uint64_t st= art, size_t length) =20 trace_ram_discard_range(rbname, start, length); =20 - rcu_read_lock(); + RCU_READ_LOCK_AUTO; RAMBlock *rb =3D qemu_ram_block_by_name(rbname); =20 if (!rb) { @@ -3169,8 +3164,6 @@ int ram_discard_range(const char *rbname, uint64_t st= art, size_t length) ret =3D ram_block_discard_range(rb, start, length); =20 err: - rcu_read_unlock(); - return ret; } =20 --=20 2.21.0