From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA8EAC49ED7 for ; Fri, 20 Sep 2019 15:53:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9925D208C3 for ; Fri, 20 Sep 2019 15:53:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tIOPXSpV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9925D208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e+38g/m/7RVTScoCP75Qlo4eY8goUaWwjj4LfhHzBw4=; b=tIOPXSpViEhym6 Az7Y24AvrSJMt287WQguPbOBChF5wwxVFolFI+P1TmmWwTeLJ5ePh4plIV2YccFPBfoOH2G0/bZRV 71JMR0TbLoWhhczEpYlXMxmHGKWGC89sa+Cc96TQxSVca0SzFuBLn4vWqlTpWKwCrgH1slTh4yqvW 9+2PS2/Dou8PUWVCtJN9rdDd8ObJXBCrdDym/KxofpOHLboq8+Li5uHJtxTPRBwkT2/ufayeBGp3Y sNzcxUDkTZnPVHF6sOpvbD8kW/4t/D7uPdzGa6J38BLVg9dr/21c7+/ZWnRI8RwmJgKevoM2palNS U0jrO5fWCdx7KzIxvDVQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBLDT-0003va-6g; Fri, 20 Sep 2019 15:53:03 +0000 Received: from willy by bombadil.infradead.org with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBLDQ-0003vK-Bt; Fri, 20 Sep 2019 15:53:00 +0000 Date: Fri, 20 Sep 2019 08:53:00 -0700 From: Matthew Wilcox To: Jia He Subject: Re: [PATCH v7 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared Message-ID: <20190920155300.GC15392@bombadil.infradead.org> References: <20190920135437.25622-1-justin.he@arm.com> <20190920135437.25622-4-justin.he@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190920135437.25622-4-justin.he@arm.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kaly Xin , Ralph Campbell , Andrew Morton , Suzuki Poulose , Catalin Marinas , Anshuman Khandual , linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?iso-8859-1?B?Suly9G1l?= Glisse , James Morse , linux-arm-kernel@lists.infradead.org, Punit Agrawal , Marc Zyngier , hejianet@gmail.com, Thomas Gleixner , nd@arm.com, Will Deacon , Alex Van Brunt , "Kirill A. Shutemov" , Robin Murphy Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 20, 2019 at 09:54:37PM +0800, Jia He wrote: > -static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma) > +static inline int cow_user_page(struct page *dst, struct page *src, > + struct vm_fault *vmf) > { Can we talk about the return type here? > + } else { > + /* Other thread has already handled the fault > + * and we don't need to do anything. If it's > + * not the case, the fault will be triggered > + * again on the same address. > + */ > + pte_unmap_unlock(vmf->pte, vmf->ptl); > + return -1; ... > + return 0; > } So -1 for "try again" and 0 for "succeeded". > + if (cow_user_page(new_page, old_page, vmf)) { Then we use it like a bool. But it's kind of backwards from a bool because false is success. > + /* COW failed, if the fault was solved by other, > + * it's fine. If not, userspace would re-fault on > + * the same address and we will handle the fault > + * from the second attempt. > + */ > + put_page(new_page); > + if (old_page) > + put_page(old_page); > + return 0; And we don't use the return value; in fact we invert it. Would this make more sense: static inline bool cow_user_page(struct page *dst, struct page *src, struct vm_fault *vmf) ... pte_unmap_unlock(vmf->pte, vmf->ptl); return false; ... return true; ... if (!cow_user_page(new_page, old_page, vmf)) { That reads more sensibly for me. We could also go with returning a vm_fault_t, but that would be more complex than needed today, I think. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel