From patchwork Thu Nov 22 07:20:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10693603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EEB615A7 for ; Thu, 22 Nov 2018 07:22:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61A172CBCB for ; Thu, 22 Nov 2018 07:22:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55E3D2CBD8; Thu, 22 Nov 2018 07:22:13 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 7D1942CBCB for ; Thu, 22 Nov 2018 07:22:11 +0000 (UTC) Received: from localhost ([::1]:44379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPjJS-0003hh-NJ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Nov 2018 02:22:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPjI6-0002gZ-PY for qemu-devel@nongnu.org; Thu, 22 Nov 2018 02:20:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPjI1-0001mw-So for qemu-devel@nongnu.org; Thu, 22 Nov 2018 02:20:46 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:45932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPjI1-0001lo-MD for qemu-devel@nongnu.org; Thu, 22 Nov 2018 02:20:41 -0500 Received: by mail-pf1-x443.google.com with SMTP id g62so1485358pfd.12 for ; Wed, 21 Nov 2018 23:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8yuKyyw8d4l95Odfc54RiKR7Oe6eGv/wZcUX85zjzVA=; b=fTfpmCft4PTzkGnE09K2JFzCUG1MNp4nj1q/RwYt4+W7IBHkl+E45kMJNMhwKJrxMZ AIaAqvO3gkEJzdvfWdEHOJjvVRf2UO7nlUPda501yeflFYfHlvdj2dGJ48fcujbv709u e14uYsMKvse/ptCnjXPGLLlYBMEVRbHORCVUydnoZF+8YnNs9YLPF1vVjyy2gFNXeeeT HVwkRucMH0aE+On8w5E32We9jcCmGCZ12OjmcYQrjTmV7qCYt2fBTqOjLIcCI6AHYdrV dlFN/Ppxv1xOIo4ZFUSzE7vIB6K886dlWczh2rX/MfdlxAWzerR3RS26YHG231R5EzkV Khiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8yuKyyw8d4l95Odfc54RiKR7Oe6eGv/wZcUX85zjzVA=; b=CzO2beuwL/gx+OtO2qkX3kOZHyPTpQQoKG60MwJA+TVdSk0JlV0+8LZSe3CXwe+TMq yv2/zN8LSMipEcgCDbd/gheXCTuOgGTirfQz5+L4Jq+aUqe1s7VFXb/WJkQQW9bjxNwo 9tnix0Pb4Kb+6IQFe56eYvwFxgt98UmedzBXikrp46DhAhqDJakCCZlPFPXFjmCdZMLw g6qDiZmnyNTeedOk2W+6BI++8AtKpk1LLqS0oKVS6foEaMVM6GBoknmq/KBawvbjWC2L 3pvw+RKSAhFOm7sLszXcZJn7xq7NLs6JudmTxfQ28+ziFY64dx56ws8BUSDr/WzkMFIq lLSA== X-Gm-Message-State: AA+aEWYkq2L7O3kpp5g3H5lptTOw5GCTG7hlpsfr0OSEwwXiuRBrqs8D R64ADsSN5szjZiuy+Jt6wgg= X-Google-Smtp-Source: AJdET5eVKFUZJJZQsiU0j9H9aInN5gEHJNj52CgJnvTilAMZNE5Vc9MeJj53tWuLezulXR4zJbumPA== X-Received: by 2002:a63:f141:: with SMTP id o1mr9135320pgk.134.1542871240862; Wed, 21 Nov 2018 23:20:40 -0800 (PST) Received: from localhost.localdomain ([203.205.141.36]) by smtp.gmail.com with ESMTPSA id 19sm52731312pfs.108.2018.11.21.23.20.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Nov 2018 23:20:40 -0800 (PST) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Date: Thu, 22 Nov 2018 15:20:24 +0800 Message-Id: <20181122072028.22819-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181122072028.22819-1-xiaoguangrong@tencent.com> References: <20181122072028.22819-1-xiaoguangrong@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v3 1/5] bitops: introduce change_bit_atomic 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: kvm@vger.kernel.org, quintela@redhat.com, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, cota@braap.org, jiang.biao2@zte.com.cn Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong It will be used by threaded workqueue Signed-off-by: Xiao Guangrong Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- include/qemu/bitops.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index 3f0926cf40..c522958852 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -79,6 +79,19 @@ static inline void change_bit(long nr, unsigned long *addr) *p ^= mask; } +/** + * change_bit_atomic - Toggle a bit in memory atomically + * @nr: Bit to change + * @addr: Address to start counting from + */ +static inline void change_bit_atomic(long nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + atomic_xor(p, mask); +} + /** * test_and_set_bit - Set a bit and return its old value * @nr: Bit to set