From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752479AbdLLSDD (ORCPT ); Tue, 12 Dec 2017 13:03:03 -0500 Received: from mail-qt0-f174.google.com ([209.85.216.174]:40080 "EHLO mail-qt0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752077AbdLLSDB (ORCPT ); Tue, 12 Dec 2017 13:03:01 -0500 X-Google-Smtp-Source: ACJfBouvMz4Yp02Q1xerC7fy0kOp1B/6mqMFoIks9x9LmnC5LtsUDIZf4WAp3j8KQFeAo/h9qe3uzw== Date: Tue, 12 Dec 2017 10:02:58 -0800 From: Tejun Heo To: Peter Zijlstra Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org, oleg@redhat.com, kernel-team@fb.com, osandov@fb.com Subject: Re: [PATCH 2/6] blk-mq: replace timeout synchronization with a RCU and generation based scheme Message-ID: <20171212180258.GH3919388@devbig577.frc2.facebook.com> References: <20171209192525.982030-1-tj@kernel.org> <20171209192525.982030-3-tj@kernel.org> <20171212100935.dogysanf52mlwsau@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171212100935.dogysanf52mlwsau@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Peter. On Tue, Dec 12, 2017 at 11:09:35AM +0100, Peter Zijlstra wrote: > > + /* > > + * ->aborted_gstate is used by the timeout to claim a specific > > + * recycle instance of this request. See blk_mq_timeout_work(). > > + */ > > + struct u64_stats_sync aborted_gstate_sync; > > + u64 aborted_gstate; > > So I dislike that u64_stats_sync thingy. Esp when used on a single > variable like this. Hmm... I see. > There are two alternatives, but I don't understand the code well enough > to judge the trade-offs. > > 1) use gstate_seq for this too; yes it will add some superfluous > instructions on 64bit targets, but if timeouts are a slow path > this might not matter. For aborted_gstate, the heavier reader side is the completion hot path. That's two rmbs, which in itself isn't too much but is still difficult to justify. > 2) use the pattern we use for cfs_rq::min_vruntime; namely: > > u64 aborted_gstate > #ifdef CONFIG_64BIT > u64 aborted_gstate_copy; > #endif > > > static inline void blk_mq_rq_set_abort(struct rq *rq, u64 gstate) > { > rq->aborted_gstate = gstate; > #ifdef CONFIG_64BIT > smp_wmb(); > rq->aborted_gstate_copy = gstate; > #endif > } > > static inline u64 blk_mq_rq_get_abort(struct rq *rq) > { > #ifdef CONFIG_64BIT > u64 abort, copy; > > do { > copy = rq->aborted_gstate_copy; > smp_rmb(); > abort = rq->aborted_gstate; > } while (abort != copy); > > return abort; > #else > return rq->aborted_gstate; > #endif > } > > which is actually _faster_ than the u64_stats_sync stuff (for a > single variable). Hmm... doing the seq reading on the variable content itself, so if we had something like this as library, I'd be happy to use it but I really don't want to open-code this. > But it might not matter; I just dislike that thing, could be me. I'll leave it as-is for now. Probably the right thing to do in the longer term is adding the seq-reading-by-content-thing in the library. Thanks. -- tejun