From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001AbdJCQLZ (ORCPT ); Tue, 3 Oct 2017 12:11:25 -0400 Received: from mail-it0-f48.google.com ([209.85.214.48]:50623 "EHLO mail-it0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750830AbdJCQLX (ORCPT ); Tue, 3 Oct 2017 12:11:23 -0400 X-Google-Smtp-Source: AOwi7QC1c6TQSz0pGTQk5p5GAC8u1xV9T7avseEcuneKqey5T2MKs1+cpGSML13wUky9qunt5OWqoQ== Subject: Re: [PATCH 10/12] writeback: only allow one inflight and pending full flush To: Matthew Wilcox Cc: Linus Torvalds , Andrew Morton , Linux Kernel Mailing List , linux-fsdevel , Johannes Weiner , Jan Kara References: <1506543239-31470-1-git-send-email-axboe@kernel.dk> <1506543239-31470-11-git-send-email-axboe@kernel.dk> <20170928144100.e11801ef742521e0e3f4b8df@linux-foundation.org> <552d4502-0b0a-87fc-7b16-6b322c3af3ed@kernel.dk> <20171003160610.GA32309@bombadil.infradead.org> From: Jens Axboe Message-ID: Date: Tue, 3 Oct 2017 10:11:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171003160610.GA32309@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/03/2017 10:06 AM, Matthew Wilcox wrote: > On Fri, Sep 29, 2017 at 02:17:32AM +0200, Jens Axboe wrote: >> On 09/28/2017 11:44 PM, Linus Torvalds wrote: >>> On Thu, Sep 28, 2017 at 2:41 PM, Andrew Morton >>> wrote: >>>> >>>> test_and_set_bit()? >>> >>> If there aren't any atomicity concerns (either because of higher-level >>> locking, or because racing and having two people set the bit is fine), >>> it can be better to do them separately if the test_bit() is the common >>> case and you can avoid dirtying a cacheline that way. >>> >>> But yeah, if that is the case, it might be worth documenting, because >>> test_and_set_bit() is the more obviously appropriate "there can be >>> only one" model. >> >> It is documented though, but maybe not well enough... >> >> I've actually had to document/explain it enough times now, that it >> might be worth making a general construct. Though it has to be >> used carefully, so perhaps it's better contained as separate use >> cases. > > test_and_test_and_set_bit()? It's an unusual name, so when either > reading it or writing it, people are going to say "something unusual > here", rather than "That Jens Axboe is such a n00b, he doesn't know how > to use test_and_set_bit()". There are a few references out on the web > to test-and-test-and-set already, so it's not entirely unique to Linux. > > Plus, some architectures might be able to optimise that, particularly > those which are ll/sc based. It might be exactly the same as their > test_and_set(). I like that suggestion, but would suggest we make it test_then_test_and_set_bit() since the 'then' naming would work for having similar test_then_clear_bit() and not clash with test_and_set_bit(). And yes, some archs would be able to optimize this nicely. All worth it if I never have to explain it or add special comments about it again :-) -- Jens Axboe