Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp636383ybg; Mon, 1 Jun 2020 10:20:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdObD5lL8vtqhCWeYJPMl2y6Y32cKa2tqFG/L63+Q2llYCkyjclzwPOp4DHmj5TK8eRA0g X-Received: by 2002:a17:906:600a:: with SMTP id o10mr21152833ejj.544.1591032017419; Mon, 01 Jun 2020 10:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591032017; cv=none; d=google.com; s=arc-20160816; b=m4CJSBtxNfcvnM0uePNn+AjrHH3qL5D+TLNDlzTWC66iH1pEz2nsyL8V+5cRiYfLAU OeEgNJ0AVnB8vzfmf2Je+Vedo7nhi3NHq9muMq2TFWNwU2AZj4+msPOWY4qqFh7cqC5Q alLIJD8Me9Vfny4IwJyhpx22DnVCZ3ivk/8Kkqnm7U3uDbQpgOJps65VHi2zf7Y/SiUA NoS4sFm05aqTjuxkG/CXFhZfnxLdTJUv7uif2pUVIfvPgEgxe8McMcGPfp5snxk+5uxU QyFND002BtbCH4ymGVuG0o/fDsB4foUYWImOTf/F7zAxnebPIcgv8PI2y4gtEwqy5jwO SoSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=WsYNSM2tJ88YCalPymb6HrMzWTrL06Vmn6FYR6YE7/Y=; b=IZ+Le9qUhf6lomAT/1UTLlmNtVvMY9SVhRGoI8GGJvrHCV9MsJC8gKX2VeTcUGPKho 0pXeBxDu61KVcGd8Vi2mNn+xwOEpb9gbMKYU5TJ6TxqjGeV25fqcitKz9vF1RaRW+YpW kNc22aeg2ZwfQrW1jILKgRZUcfJPuOrk7740s2J0AcHaH1dQldF58uq24TuCNPyK6Bca B9jfVfaEb0eLg59xB7y+lV2jw2VvyMvODQX4DunU3sAtO8HeVtPv7nckMlZ7izuHmg1A ySL5/VqLvB0ysFaVZT/wrBkqjHaewLN9/7ZV/RJY+y8fjkJebhcbl1hU7KNDCadyuM96 BM7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=UgTmTyPN; 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 t25si50185ejd.627.2020.06.01.10.19.54; Mon, 01 Jun 2020 10:20:17 -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=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=UgTmTyPN; 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 S1727924AbgFARPZ (ORCPT + 99 others); Mon, 1 Jun 2020 13:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgFARPZ (ORCPT ); Mon, 1 Jun 2020 13:15:25 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8337C05BD43 for ; Mon, 1 Jun 2020 10:15:24 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id fs4so99756pjb.5 for ; Mon, 01 Jun 2020 10:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WsYNSM2tJ88YCalPymb6HrMzWTrL06Vmn6FYR6YE7/Y=; b=UgTmTyPNErDWoyfDpvqEdQs/U0cshfD8CeAre29uvZ/dsDLiaKCLIx+B0hmevfnub2 0tDRZhun5AbIaUe8SBeRwV24cBYLkx5zGsLhc5btRwWKuuENnv81W1XD4EzHeU2TFL+Y YPXWGNMQB3ZfSNqm0aK6qvPU8H0P/AAcN3ohrkN+vUQc1U37ZPjHjGoxZ9FQoEXx9fFM 1wtG0Pg1H2Xqifo4XuQFBFtIU8HsukcHZMHwyTUDR+6WV7LFfjpVnCxNeUYBZQCA+ERb +nkfqnqnfPlKH2LndTUNPgXx9+YkQF0yCX5ZGsn9nw2tkdHaJ11TlFd+n8Tq7PTfxJdJ qQXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WsYNSM2tJ88YCalPymb6HrMzWTrL06Vmn6FYR6YE7/Y=; b=WqCWTBbOFilljMLzxczXH4LvtvE68A4vthZ5f4i/gkPQFGSTiGgzr3VcApELXUvzkv TPdbiobGnIhDV36nwmJWMlfdsXlF6zogokR8fQ4Rg2+6/d5Sx7GEP9WeSQh9XWdVByov snzjECHdcPCW32v1jPE9i8mxNT1BO6wktKZdtmQaZ8UzWp/TidnMxTNKlL/JPYIwxwAl D7IQwD39lB86nammF8ZPVwcEvq9OFlgHZjx6esG3NLuoN0kNaAPYof068qtJsWckWl/X RCIb7R7igLiXNqOD+aU94xvpwxC2pL/ZdeJqdAJjsx5nM6vdFh2j5qemaFomGf4F2Ds6 AeqA== X-Gm-Message-State: AOAM530XFxcwnS/IxyMA4jGOn+AbqCfVwSpBfWk4hGfBybK/7N50pLGn pyIgbkHSHLFZbzzh3EEGIDMcUxhKcbrGKA== X-Received: by 2002:a17:90a:4d4e:: with SMTP id l14mr470026pjh.10.1591031724348; Mon, 01 Jun 2020 10:15:24 -0700 (PDT) Received: from [192.168.1.188] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id mg14sm33297pjb.48.2020.06.01.10.15.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 10:15:23 -0700 (PDT) Subject: Re: [PATCH 04/12] mm: add support for async page locking To: Matthew Wilcox Cc: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org References: <20200526195123.29053-1-axboe@kernel.dk> <20200526195123.29053-5-axboe@kernel.dk> <20200601142649.GJ19604@bombadil.infradead.org> From: Jens Axboe Message-ID: <2f4dbb05-4874-6386-f9ee-06fdbaf482bf@kernel.dk> Date: Mon, 1 Jun 2020 11:15:22 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200601142649.GJ19604@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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/1/20 8:26 AM, Matthew Wilcox wrote: > 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. That's probably true, and we can skip the 2nd one. I'll make the change. -- Jens Axboe