Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp520235ybg; Mon, 1 Jun 2020 07:29:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi4Blm36pEkCmiFXXSZtG4wNBtMRUk0O+Q7YSCf7I8zxPo8P0FxFCk4tdlIJ7zaYWIrapE X-Received: by 2002:aa7:d5c7:: with SMTP id d7mr22306916eds.11.1591021744391; Mon, 01 Jun 2020 07:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591021744; cv=none; d=google.com; s=arc-20160816; b=umYHo/tlJHA3oatooB6ckC237pCJVc+99Q+TToxHeN4cVGyVp9JG3d+ZmNfYRRyZco TrQ/hzdZr5l0K7hK4dcGWM2sM0B8gcYD2e0c+xtDlowTW9wKZGgOpVT0W3ZFkIwV445Z 61e9W3pI3H7A6+ksjJQFccjITs7O6euCoQcYCFqWbf3BwNWo0ua0Wyq26QbuK6l9zRfn 0ZIvx7VsiNXkKRb5rQr7l9/p7XieLpOXn0/e9mecmn5YIUKWaxkoh8Su+QVaDKT7n8d8 FBGnXs/glrXNfiVMqcs2YM8By/QAgQ+AuMayfaUOwWWmEDxovS0UTfHj2JCw8AbAqHhd dbMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qcaW7kM1FeNeZDxjYDiBD+HVABREC6q8IwJJi9uWfas=; b=vVQLXgbd3LaBwRwdxEutruevyOf35qcVqW/c3mS0bUL1bLexZwywDGMxw2nt8PPXei XpTy7KRJ9ZqZgK1pf4TYOM/DFXn2dKwtgSUy886XSMGDspOCN4Yug2zRxKEXPlPOvxUd A1eWtLuVFzDiuAoVAYF743ZMFdvXI4gzQmxebqRebjDRM0GcgDpZDDTpfdMrjUIF10P/ TD46aas/OO0U2ErZwbfSmmjQ4akoSua6o5QePzW1d2B/ziTADlnabyIECgYVeQL/oq1v tmhDJxMbbeGMnCpOzYp2G11duqJ62+R2q40zVMg03AyHkK8Lc4RY82ZWFX0PsCG9ACdw qO+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=WMihkXKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si11712292edl.221.2020.06.01.07.28.40; Mon, 01 Jun 2020 07:29:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=WMihkXKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726289AbgFAO0u (ORCPT + 99 others); Mon, 1 Jun 2020 10:26:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgFAO0u (ORCPT ); Mon, 1 Jun 2020 10:26:50 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA7B9C05BD43; Mon, 1 Jun 2020 07:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qcaW7kM1FeNeZDxjYDiBD+HVABREC6q8IwJJi9uWfas=; b=WMihkXKOcI2hSSU0oFKHkV0u1r Le+5snAEEYV9wkCUV0VMA+ifWaY0vKrtJGErZFhk1nmn4mPayyHGEcF1rgQvQOjrwpJwQt0gy+Zhw 3degdL1kgxN7ESOBhBORSVuMTraNHVDmU47PF9Pw+rQGyPi+qmSKYAb6xYytsDvS56vz+dPR2h3oW 9KUBAdmvnMXdj6UE7/f0yGP9Mcjja6M92/tiG1fHBBH2FkwTvKIbQ0q2e3brpYhKrfnfk61uQ0dIB RqOn0IV+1LLV+NnAdgSPw4WzHumgD+TttCYxuwfiP1K5L3U8MSe/hT7C7FvnGbglsOPRyC4/T8aZ5 cdMRLDng==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jflOr-0003DU-I3; Mon, 01 Jun 2020 14:26:49 +0000 Date: Mon, 1 Jun 2020 07:26:49 -0700 From: Matthew Wilcox To: Jens Axboe Cc: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org Subject: Re: [PATCH 04/12] mm: add support for async page locking Message-ID: <20200601142649.GJ19604@bombadil.infradead.org> References: <20200526195123.29053-1-axboe@kernel.dk> <20200526195123.29053-5-axboe@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200526195123.29053-5-axboe@kernel.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 26, 2020 at 01:51:15PM -0600, Jens Axboe wrote: > +static int __wait_on_page_locked_async(struct page *page, > + struct wait_page_queue *wait, bool set) > +{ > + struct wait_queue_head *q = page_waitqueue(page); > + int ret = 0; > + > + wait->page = page; > + wait->bit_nr = PG_locked; > + > + spin_lock_irq(&q->lock); > + if (set) > + ret = !trylock_page(page); > + else > + ret = PageLocked(page); > + if (ret) { > + __add_wait_queue_entry_tail(q, &wait->wait); > + SetPageWaiters(page); > + if (set) > + ret = !trylock_page(page); > + else > + ret = PageLocked(page); Between the callers and this function, we actually look at PG_lock three times; once in the caller, then after taking the spinlock, then after adding ourselves to the waitqueue. I understand the first and third, but is it really worth doing the second test? It feels unlikely to succeed and only saves us setting PageWaiters.