From patchwork Mon May 23 15:09:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9132031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E9FB60761 for ; Mon, 23 May 2016 15:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 756112822F for ; Mon, 23 May 2016 15:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A6C428239; Mon, 23 May 2016 15:20:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 897CC2822F for ; Mon, 23 May 2016 15:20:28 +0000 (UTC) Received: from localhost ([::1]:48843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4red-0002JX-7C for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 May 2016 11:20:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4rUu-0002Ht-Oe for qemu-devel@nongnu.org; Mon, 23 May 2016 11:10:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4rUj-00044a-BC for qemu-devel@nongnu.org; Mon, 23 May 2016 11:10:23 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4rUj-00044N-4c for qemu-devel@nongnu.org; Mon, 23 May 2016 11:10:13 -0400 Received: by mail-wm0-x241.google.com with SMTP id 67so16035809wmg.0 for ; Mon, 23 May 2016 08:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=vqnOZVwwaUlycN68znOq+nFGqPYvmt6lA2t6OnM8Zrs=; b=HlDCsn7gWSXfzjMkIR+ir0APHiAM/qAy8nKXS+aU3P9G6bfqs76DgJOolMao9I0RaK CCdVJH92a9JENLK7Ay084rTs70DmwCg6byf8GVtsN2EuhOCkvW6Oihvdqrlr9d3PAwiA Kgzja2B9T89ZP3tlA1vWR9OSDBA0KALAb6gL8jYFW4YheOd0SmkGhw7g+MCHQNsFAIOP smlUbjNjzt7mDsnUqsZ6us4dYp1piITm7Zre/+QfUUOQm22Pn25F1REZaLm+31i4KcQp qPd8+sOyb9Ug1QH6CBVwgs0dHMOseKObBCz/8LGuO9M/qH033GQ/PiFdyBHYrrZIAawQ Grdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=vqnOZVwwaUlycN68znOq+nFGqPYvmt6lA2t6OnM8Zrs=; b=lJgr2qaj6Pvs/Ox+s+wAiogCeSEpuxKpvQVsJl9geMQK15OTERl9pf1jEBqtB9oZfV C1BQ1DuXdoZQFUZyxv8XWLhMrlNYxQLI/VVOV9qKOessjJhh7KW1H+c79l6zvT4Q94f3 cQPBDj29DfneVk+f6DGNsSYM6O4ag/RMf6cQZBvtZFXq6RhZFhnmNss+7qVwrs1/hC8y Axti1QmBLAX8mFCfbz1wImzqy/7JlrIJLc3c06x+OjSMRY/SDgG6zLHtilRN4e5dZxti g7Jk61eolrR2Ph6FQYjNKw90jdPtAPm/4OaR7TazRdDp/F4My/4LRpMerDv9Hat1+GOB BjRA== X-Gm-Message-State: AOPr4FUhMsbQXC+yTLKKpLXyAIwKXu9r4rdY7LnYQDb6eEHckt6md31gjnPlF0uJtGHxUA== X-Received: by 10.194.47.74 with SMTP id b10mr16719444wjn.4.1464016212598; Mon, 23 May 2016 08:10:12 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-252-58.clienti.tiscali.it. [78.12.252.58]) by smtp.gmail.com with ESMTPSA id ac2sm19250359wjc.35.2016.05.23.08.10.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 May 2016 08:10:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 23 May 2016 17:09:45 +0200 Message-Id: <1464016199-43768-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1464016199-43768-1-git-send-email-pbonzini@redhat.com> References: <1464016199-43768-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 10/24] 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: Gonglei Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gonglei 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 Message-Id: <1462845901-89716-3-git-send-email-arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini --- exec.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/exec.c b/exec.c index e2966ce..8cf535d 100644 --- a/exec.c +++ b/exec.c @@ -1421,8 +1421,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]); @@ -1435,6 +1433,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)) { @@ -1453,12 +1452,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)