From patchwork Tue May 10 02:05:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9053071 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CB5C9BF29F for ; Tue, 10 May 2016 02:05:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11F0F20114 for ; Tue, 10 May 2016 02:05:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85CD12010E for ; Tue, 10 May 2016 02:05:55 +0000 (UTC) Received: from localhost ([::1]:43944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azx3Y-0005d4-DK for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 May 2016 22:05:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azx3P-0005ZG-MW for qemu-devel@nongnu.org; Mon, 09 May 2016 22:05:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1azx3M-000432-93 for qemu-devel@nongnu.org; Mon, 09 May 2016 22:05:43 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:45101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1azx3L-00042U-I5 for qemu-devel@nongnu.org; Mon, 09 May 2016 22:05:40 -0400 Received: from 172.24.1.60 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.60]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DGX42849; Tue, 10 May 2016 10:05:18 +0800 (CST) Received: from localhost (10.177.18.62) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Tue, 10 May 2016 10:05:08 +0800 From: Gonglei To: Date: Tue, 10 May 2016 10:05:00 +0800 Message-ID: <1462845901-89716-3-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1462845901-89716-1-git-send-email-arei.gonglei@huawei.com> References: <1462845901-89716-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.573141DF.0107, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d763a8525e515e7695c7ae608bb0dbbc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH v2 2/3] exec: adjust rcu_read_lock requirement X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Gonglei , famz@redhat.com, peter.huangpeng@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP qemu_ram_unset_idstr() doesn't need rcu lock anymore, meanwhile make the range of rcu lock in qemu_ram_set_idstr() as small as possible. Signed-off-by: Gonglei --- exec.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/exec.c b/exec.c index c840bc7..117c9a8 100644 --- a/exec.c +++ b/exec.c @@ -1417,8 +1417,6 @@ void qemu_ram_set_idstr(RAMBlock *new_block, const char *name, DeviceState *dev) { RAMBlock *block; - rcu_read_lock(); - assert(new_block); assert(!new_block->idstr[0]); @@ -1431,6 +1429,7 @@ void qemu_ram_set_idstr(RAMBlock *new_block, const char *name, DeviceState *dev) } pstrcat(new_block->idstr, sizeof(new_block->idstr), name); + rcu_read_lock(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { if (block != new_block && !strcmp(block->idstr, new_block->idstr)) { @@ -1449,12 +1448,9 @@ void qemu_ram_unset_idstr(RAMBlock *block) * migration. Ignore the problem since hot-unplug during migration * does not work anyway. */ - - rcu_read_lock(); if (block) { memset(block->idstr, 0, sizeof(block->idstr)); } - rcu_read_unlock(); } static int memory_try_enable_merging(void *addr, size_t len)