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.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 E1E16C4CEC9 for ; Fri, 20 Sep 2019 15:53:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A28BC208C3 for ; Fri, 20 Sep 2019 15:53:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hETyHfgl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A28BC208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 34E7B6B0006; Fri, 20 Sep 2019 11:53:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FEA06B0007; Fri, 20 Sep 2019 11:53:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C6CB6B0008; Fri, 20 Sep 2019 11:53:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id EF4D16B0006 for ; Fri, 20 Sep 2019 11:53:10 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 945B3181AC9B4 for ; Fri, 20 Sep 2019 15:53:10 +0000 (UTC) X-FDA: 75955742940.04.leg79_72b6bc43b0c59 X-HE-Tag: leg79_72b6bc43b0c59 X-Filterd-Recvd-Size: 4178 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Sep 2019 15:53:08 +0000 (UTC) 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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ehfHqKGq02VDpyHgsdO6CgZKeSAkHux13i46LeTOUmM=; b=hETyHfglQKP6WR4B6RG5ZmaQD 95C2f8tvVoss9pKS2CCwzh/44MR1IyzmMPxDliQc4yCQ4itL0mJex15dHhpw1ucGzyvOIO7o/jsr7 jofX0RjUj16USAEJCkU3VblfmrZvkT5X3grzhzOtxns4zR2HeKwp0ROGCYgr/6BZWsnrt9hrMJC3U bETYi0g+1ASXehjzUWv0+6FhtyBB+Nw3ivPf83z/RYRa49ay5KeoJIdddaB1O9dxBB6XaaxuRiInX rHEQfzmMWnXGaWIFmspCPjhFUtiTIqXfCX4myMqxSQyzp0jeHAhd2Ls8a2bZrR+3pzmi6iObihOnT tQ1driPtQ==; 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 Cc: Catalin Marinas , Will Deacon , Mark Rutland , James Morse , Marc Zyngier , "Kirill A. Shutemov" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Suzuki Poulose , Punit Agrawal , Anshuman Khandual , Alex Van Brunt , Robin Murphy , Thomas Gleixner , Andrew Morton , =?iso-8859-1?B?Suly9G1l?= Glisse , Ralph Campbell , hejianet@gmail.com, Kaly Xin , nd@arm.com 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190920135437.25622-4-justin.he@arm.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.