From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Dr. David Alan Gilbert" Subject: Re: [PATCH v3 1/5] bitops: introduce change_bit_atomic Date: Fri, 23 Nov 2018 10:23:35 +0000 Message-ID: <20181123102334.GB2373@work-vm> References: <20181122072028.22819-1-xiaoguangrong@tencent.com> <20181122072028.22819-2-xiaoguangrong@tencent.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, mst@redhat.com, mtosatti@redhat.com, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, quintela@redhat.com, wei.w.wang@intel.com, cota@braap.org, jiang.biao2@zte.com.cn, pbonzini@redhat.com To: guangrong.xiao@gmail.com Return-path: Content-Disposition: inline In-Reply-To: <20181122072028.22819-2-xiaoguangrong@tencent.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel2=m.gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org * guangrong.xiao@gmail.com (guangrong.xiao@gmail.com) wrote: > From: Xiao Guangrong > > It will be used by threaded workqueue > > Signed-off-by: Xiao Guangrong Reviewed-by: Dr. David Alan Gilbert > --- > 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 > -- > 2.14.5 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gQ8cr-0000o7-6Y for qemu-devel@nongnu.org; Fri, 23 Nov 2018 05:23:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gQ8cn-0008JH-7Z for qemu-devel@nongnu.org; Fri, 23 Nov 2018 05:23:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48086) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gQ8cn-0008Ik-2Y for qemu-devel@nongnu.org; Fri, 23 Nov 2018 05:23:49 -0500 Date: Fri, 23 Nov 2018 10:23:35 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20181123102334.GB2373@work-vm> References: <20181122072028.22819-1-xiaoguangrong@tencent.com> <20181122072028.22819-2-xiaoguangrong@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181122072028.22819-2-xiaoguangrong@tencent.com> Subject: Re: [Qemu-devel] [PATCH v3 1/5] bitops: introduce change_bit_atomic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: guangrong.xiao@gmail.com Cc: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, peterx@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn, eblake@redhat.com, quintela@redhat.com, cota@braap.org, Xiao Guangrong * guangrong.xiao@gmail.com (guangrong.xiao@gmail.com) wrote: > From: Xiao Guangrong > > It will be used by threaded workqueue > > Signed-off-by: Xiao Guangrong Reviewed-by: Dr. David Alan Gilbert > --- > 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 > -- > 2.14.5 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK