From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v3 2/5] util: introduce threaded workqueue Date: Mon, 26 Nov 2018 16:18:24 +0800 Message-ID: <122f7c3b-ebaf-a2c0-3181-cce82d857058@gmail.com> References: <20181122072028.22819-1-xiaoguangrong@tencent.com> <20181122072028.22819-3-xiaoguangrong@tencent.com> <20181124001734.GF17229@flamenco> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, mst@redhat.com, mtosatti@redhat.com, Xiao Guangrong , dgilbert@redhat.com, peterx@redhat.com, qemu-devel@nongnu.org, quintela@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn, pbonzini@redhat.com To: "Emilio G. Cota" Return-path: In-Reply-To: <20181124001734.GF17229@flamenco> Content-Language: en-US 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 On 11/24/18 8:17 AM, Emilio G. Cota wrote: > On Thu, Nov 22, 2018 at 15:20:25 +0800, guangrong.xiao@gmail.com wrote: >> +static uint64_t get_free_request_bitmap(Threads *threads, ThreadLocal *thread) >> +{ >> + uint64_t request_fill_bitmap, request_done_bitmap, result_bitmap; >> + >> + request_fill_bitmap = atomic_rcu_read(&thread->request_fill_bitmap); >> + request_done_bitmap = atomic_rcu_read(&thread->request_done_bitmap); >> + bitmap_xor(&result_bitmap, &request_fill_bitmap, &request_done_bitmap, >> + threads->thread_requests_nr); > > This is not wrong, but it's a big ugly. Instead, I would: > > - Introduce bitmap_xor_atomic in a previous patch > - Use bitmap_xor_atomic here, getting rid of the rcu reads Hmm, however, we do not need atomic xor operation here... that should be slower than just two READ_ONCE calls.