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: 10693591 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 17BEF5A4 for ; Thu, 22 Nov 2018 07:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBD102CBBB for ; Thu, 22 Nov 2018 07:20:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF2A12CBD5; Thu, 22 Nov 2018 07:20:42 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 870592CBBB for ; Thu, 22 Nov 2018 07:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392549AbeKVR6t (ORCPT ); Thu, 22 Nov 2018 12:58:49 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35787 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392545AbeKVR6t (ORCPT ); Thu, 22 Nov 2018 12:58:49 -0500 Received: by mail-pf1-f196.google.com with SMTP id z9so1506121pfi.2 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=XBtNTLW0DtPxHaAdljycX9q7wmEjdHNvrK0lGCk8O21mUAH0ArWsOsfRj7Q9wyBvJB /D0curvqGbIAWDS7OEI486sN+xxVhbeMB3zPKn2DdFT4deODbFyNvwIMx5z6EcI6x0vC 42apzjnWrOV5gnvujRlTl879tBwWlbGttHVD3r527QqzBBtP4mBQN4gRcNXr1/LbM/1R //16j/vDlepaI9cmxcYDKscG5k6s/S5GeRlBDbh4R/S3e/c8cjpqjllDJ+xT4otMs/Ed KZzH5wFLXIJx+ny9HhVQ9HSCzosEmJfXa/7+Oe/Kte9llKJDSiNgl6U1fhnlrk/2kypV Um9w== X-Gm-Message-State: AA+aEWaJgjkrsn4M9q60H/obcWDIH3Uwx76X03iizW4+JKEZRcnr0BW1 6x9jcQFL8Holu78suu5wG+I= 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 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn, eblake@redhat.com, quintela@redhat.com, cota@braap.org, Xiao Guangrong Subject: [PATCH v3 1/5] bitops: introduce change_bit_atomic 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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