From patchwork Tue Nov 6 12:20:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 993657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ed2frqWQ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42q7yY2RG3z9sBN for ; Tue, 6 Nov 2018 23:24:21 +1100 (AEDT) Received: from localhost ([::1]:40675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK0P4-00079B-Rk for incoming@patchwork.ozlabs.org; Tue, 06 Nov 2018 07:24:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK0LZ-0002mQ-4H for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:20:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK0LX-0001fE-88 for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:20:41 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:43086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK0LW-0001cT-3U for qemu-devel@nongnu.org; Tue, 06 Nov 2018 07:20:38 -0500 Received: by mail-pf1-x444.google.com with SMTP id g7-v6so3773271pfo.10 for ; Tue, 06 Nov 2018 04:20:37 -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=Ed2frqWQ0WCOTbULrLvVYoXHc41bwO1VJwCbNB+rA5kQlcT9Wo9de6oxqBWmjoggQw K1zZsZsZiB+T9+jt8UKO+w7vqpRqK1c35f5DCNoH6B4fRGNKG6V+frn3gyvQb7rfA8GO FU1GEtlIK6yCoU4+QUcu7q4xTLHRaO/WUNMo4P2chDrMX+qIPg6ngcV4WLSoxF+hPg6g o8dZ8q5WTySeLkQtG10a3YX5H9FPhzlZFZUhTLxr2KtsrQ5lT/EXDBBJ/xZyiOz3E/3L +imawpKFwcF/8jrhZrYXaAXuGSIH0VoqUeVWKOCGtEnDj28LfS+zZdLJiSoo0tA4fTcO 1Ltg== 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=TExyphePlirQD5++iDhCd1sxRLG2GgGR3TxoIB63o82xu0mdHrIP13R38c8PwmA+WP 3jlUSZ5GlLB7cfcnxEiZQKLAXcbMLQ2ngijTnMTA1Z5EsIr63fau9QnNEKogTjwymRqW GZfzJUfvHZfAfLZPTeyzOPfdSA7Kok988cW6FzaKueb72jN4PqGzHi9rq1OIgeu8aYto hxB2vdyrY7bIszK+pYnu7mRMUS75OobjzxT+9KKWT8ZaOwaqyiXlINmfHnVddHH/hY9b esFKLfrV6iHWF9Y4xHdMwVjQwGoP/X9rwbeOQIAB1NRIUxYzaKSHlq6YLiGhryY/qeGI BUow== X-Gm-Message-State: AGRZ1gKQNLHnOc31BgbgkJ5PT1w//cW8UxOYMyhRdQ4hbrfmp2TspGtQ 49ugOZ/Yb7rI0C6/fA+dHaQ= X-Google-Smtp-Source: AJdET5ezJWyALmDe6vfgs+Wdj/dGOO5zNbcGBQeByVDaueU5LxLPjp9ooyHLH83/Rw0OVJqm41ch6Q== X-Received: by 2002:a65:4049:: with SMTP id h9mr23246694pgp.304.1541506837191; Tue, 06 Nov 2018 04:20:37 -0800 (PST) Received: from localhost.localdomain ([203.205.141.52]) by smtp.gmail.com with ESMTPSA id v4-v6sm19050021pff.9.2018.11.06.04.20.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Nov 2018 04:20:36 -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: Tue, 6 Nov 2018 20:20:21 +0800 Message-Id: <20181106122025.3487-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181106122025.3487-1-xiaoguangrong@tencent.com> References: <20181106122025.3487-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::444 Subject: [Qemu-devel] [PATCH v2 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Xiao Guangrong It will be used by threaded workqueue Signed-off-by: Xiao Guangrong --- 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