Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1664367pxj; Wed, 19 May 2021 10:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3fI4a6IVbfZf0ZALrPqqBS2sTBLhO78Km/Ie3pHzcmTR01XuMuXAa1OQX8QiqYSMCLfox X-Received: by 2002:a05:6602:242b:: with SMTP id g11mr682560iob.105.1621447074845; Wed, 19 May 2021 10:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621447074; cv=none; d=google.com; s=arc-20160816; b=i9NbvfmPhSeAH1jbh8vHs0Ga/M2OTXPcfbWLfCpSC46XPROigYgZSCYitiyUyBRwnS PrRTtWgviUQXu810d7UdY0NZCc5CeC9R6YlGAh1Ap6c1oZq+ZTX5MdUBdx4s+X3G2WqN 0ISEh7rI8/P6MRkoCwBz7s/A51bnSv0ZK2lNS9qGCD7uIoU1iqaju4wjR5oZPsdx0W64 1aVvarFczi6ItFdtJp5GTUJ+MJcTVp08sSiY0130BrbM4X/Vb99bJkJdhx/nG9iTGVtj 7MCZimSskA+B2wObKK6npdimHijVnK/je80LDRcHtOTtwbuRZ1yUEU3tT9dob9LP2J5P nW/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bcVit+6mgvFx6heftajsrfaGxDkJsK5oc1JEKMXcvbk=; b=YZ22dc25qlHmm8cgSEnft9DDLINk/ZI2hHllZu+Dx/ZVoCDEHYQYCV6Alf48VcLTn+ kvMnQpMdhQ1ToHCPcIKhQQIwpQdyHZlIRKnqNt7TrD5KLkWdBq5Q5KO00kdzE7TlaSL+ HJjPhn6ss+O1KffV8JMbTy9MN597JI0vF+Ce2DC9YSEoFPukgvcaAHad9czwq8JE8Qyd xUqpkm80OFCuslBEhmGFTHe547+A5V09lLJ0R12sczxdEDWW03rVCnA/HTaA1SrUDM3e fYKLDP2B8rZrZZ34sUVbkwK7MiojP20KYSwpIpJPYMe7eyazWI3Zeh+bzVl8mchcymXX OXuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=t8b781qf; 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 o1si28192088jat.48.2021.05.19.10.57.42; Wed, 19 May 2021 10:57:54 -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=@infradead.org header.s=casper.20170209 header.b=t8b781qf; 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 S238548AbhERLdA (ORCPT + 99 others); Tue, 18 May 2021 07:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237487AbhERLc7 (ORCPT ); Tue, 18 May 2021 07:32:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00627C061573; Tue, 18 May 2021 04:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=bcVit+6mgvFx6heftajsrfaGxDkJsK5oc1JEKMXcvbk=; b=t8b781qfNVrmqOk36u2HkQAnOx 3W8zk/6U2ayPe7nlMCdyQKDq5sK6zToIkich1QZsLvVi4Ef40iM1NQf/c3DO2Bw5VrEd12V5SzHb+ 1cOUCYljpa9RqEfXAJRGJSCEloeSVRUtjxY3I5Zy4v61LDPhLryztZfyIO+zqSUOkZNQTZaUnvKos h1HVt1hJZP9IapTE2fnBHe/L/qbbxFtY7Ms4cork7z+pdoSjGbQGNRW1dMn5uMqcasMHRm/GyMKti vUYpR/zArMKUU2BLUwaJiCEz1z3/DGSEA+G7R31dwlBynnjx2qNl9FJxQY+ISkqeBIX+63q9u4h+B geD92rLw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lixvF-00DvfV-Dm; Tue, 18 May 2021 11:30:53 +0000 Date: Tue, 18 May 2021 12:30:01 +0100 From: Matthew Wilcox To: Vlastimil Babka Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Jeff Layton Subject: Re: [PATCH v10 18/33] mm/filemap: Add folio_unlock Message-ID: References: <20210511214735.1836149-1-willy@infradead.org> <20210511214735.1836149-19-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021 at 12:06:42PM +0200, Vlastimil Babka wrote: > > /** > > - * unlock_page - unlock a locked page > > - * @page: the page > > + * folio_unlock - Unlock a locked folio. > > + * @folio: The folio. > > * > > - * Unlocks the page and wakes up sleepers in wait_on_page_locked(). > > - * Also wakes sleepers in wait_on_page_writeback() because the wakeup > > - * mechanism between PageLocked pages and PageWriteback pages is shared. > > - * But that's OK - sleepers in wait_on_page_writeback() just go back to sleep. > > + * Unlocks the folio and wakes up any thread sleeping on the page lock. > > * > > - * Note that this depends on PG_waiters being the sign bit in the byte > > - * that contains PG_locked - thus the BUILD_BUG_ON(). That allows us to > > - * clear the PG_locked bit and test PG_waiters at the same time fairly > > - * portably (architectures that do LL/SC can test any bit, while x86 can > > - * test the sign bit). > > Was it necessary to remove the comments about wait_on_page_writeback() and > PG_waiters etc? I think so. This kernel-doc is for the person who wants to understand how to use the function, not for the person who wants to understand why the function is written the way it is. For that person, we have git log messages and other comments dotted throughout, eg the comment on clear_bit_unlock_is_negative_byte() in mm/filemap.c and the comment on PG_waiters in include/linux/page-flags.h. > > + * Context: May be called from interrupt or process context. May not be > > + * called from NMI context. > > Where did the NMI part come from? If you're in NMI context and call unlock_page() and the page has a waiter on it, we call folio_wake_bit(), which calls spin_lock_irqsave() on the wait_queue_head_t lock, which I believe cannot be done safely from NMI context (as the NMI may have interrupted us while holding that lock).