Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2270458ybj; Mon, 23 Sep 2019 00:22:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl78Xn6iSQmKrTZfuxrA2fEGzrvgofy0Bl/8Zb+88TaiNMnp/J8Wh1DB3z+SzrhgpUR3ZQ X-Received: by 2002:a50:c306:: with SMTP id a6mr11031823edb.108.1569223346089; Mon, 23 Sep 2019 00:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569223346; cv=none; d=google.com; s=arc-20160816; b=z7d3NUocZfE/BT8Rmfvtdd782NJEw1xmT51xbR/74HixOX0JiWRGB5g181AO+uGU16 8zfOH6+TiQ4ih5RE1RaiXsZpd3dNgCLcRTPXl7Gt4V8ZUC43PzptNnqVnwE58HvUROYR ewgosRncvJMtS+uOf/ZUjS7oY1crPj/LhMjacpFdVgucRjyzeDJNWlbF68WfCqWhB31G KZq5fJ44ygwOLhA0b9LSUKkQa8Wh4Srz7A/+4IzfRq4Ys/ywcWOwqFwhcRyb3+FitKgE S5n+XGZdsW0gdIemANR+u8CbCkJistFYgefcIGVgCSyeTz5oEwW/pD8UejDPoX58fgzN i5zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CoI9aEF1VTiw5Xhyqba7lfuNeKaTTzmcsltHbdSRkHo=; b=A1QY9r0fJvAlf3eZTIj8zS4VClFJ5ZtvSDIwmXilRZHBFfCDcj9QgW7/QCZEwNbNjB 42OGVyJsoKGoOmWJKjxVdP4NIn+TOGSJP3k9LpN3TrIvu4YII+uc1F0MPJBQR/1lQs6U HOWVvPuP/+nv2oCfhS8ppuJuKnkt0Lm0FM9IMevx6xaZb0SHfr0WaIn6Ri8OS7d+EdG/ dSb88k+MbUrOteBPJEzLIlQkWzE6bMW9pqK4ZwtnHeU5CvI3AfgIyRVGRd4jOmjkiSXO 7s+g3f10XDN/f21mKFnFOOPMYA3E/Rn8eqAP6YveNyyWsDd3OXSGLQJJa3tDQ1Q9szK5 ymvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=2OJhJbUb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jz14si4601425ejb.32.2019.09.23.00.22.02; Mon, 23 Sep 2019 00:22:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=2OJhJbUb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390491AbfITRAd (ORCPT + 99 others); Fri, 20 Sep 2019 13:00:33 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:41692 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388450AbfITRAd (ORCPT ); Fri, 20 Sep 2019 13:00:33 -0400 Received: by mail-ed1-f68.google.com with SMTP id f20so7132223edv.8 for ; Fri, 20 Sep 2019 10:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CoI9aEF1VTiw5Xhyqba7lfuNeKaTTzmcsltHbdSRkHo=; b=2OJhJbUbpQmn+x3xQD0IdUL9dWYC/YbYOg+H5Rw3+hLXeib7Fw/NkPDuWjgbqZRyhH UhmCvyDveVppNSNLWGUKKRYDph/8hy+GnlI9BVJWv0qh74USl2ktYfyjzTL8u4DiloGy HnmblWT8RimK7hpAAi8c6P5HsIihYVZ8Je0xC3YEpMKV9Yetl1W5YiYuZ+6wOC/Uh2Kr VZ1PH7IUzV63vSz619E375gvI6LfJ7yVXe1yfFLtVhvs0ek4tvLZGZloHPwyM+S9/UZ9 gi+hz7IU0w427OYGIpgdEyH0pB9IaeIh59t9zYXHgLMoCPNUG9Oyu/8Emo7f+Ps51Xut LF9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CoI9aEF1VTiw5Xhyqba7lfuNeKaTTzmcsltHbdSRkHo=; b=oYKyYwOxPNm2YjIa+/tBhigTDFqMlcVZiRyLkH3U1FdJg/7rrhzlKhwoP/quPR+mTs 8pTOc+uMm+pixaGBDoaW8erpJJcqOxqOmmi5hGmhA3f31dowZbbd08bo6ZkVpzXrORYp SDLJwFehI+Z28eDtmAhNaohetYg7nCSWxDJZaoV9NcCXkEL+O4Lfv5BsMviC+7VyCuMu t7YTF5d/1cI9Hp30VWA3HFbyKAWpSmdc0BB34eqV0jp0Ahei8rH8sMcUExDdQMCouVYQ bPRfn5vPzPggCHAazgZfUe6WHPP8fOn0hjBY93UIN7mkn2/9o4hA7oh88/QfU2sByBPE SsXw== X-Gm-Message-State: APjAAAXv95vEk3L9VCO/4DaXOa/x7Zw8EIdDPHWEEJd193os6CfbsfC/ Lsae3jeS7t6OlBXgeiGVz2Hr4Q== X-Received: by 2002:a17:906:5c49:: with SMTP id c9mr20265396ejr.78.1568998831579; Fri, 20 Sep 2019 10:00:31 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id jr18sm285103ejb.89.2019.09.20.10.00.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Sep 2019 10:00:30 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id DB3CE10140A; Fri, 20 Sep 2019 20:00:30 +0300 (+03) Date: Fri, 20 Sep 2019 20:00:30 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: Jia He , 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 , =?utf-8?B?SsOpcsO0bWU=?= 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: <20190920170030.bpse5rlpjodbiv62@box> References: <20190920135437.25622-1-justin.he@arm.com> <20190920135437.25622-4-justin.he@arm.com> <20190920155300.GC15392@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190920155300.GC15392@bombadil.infradead.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 20, 2019 at 08:53:00AM -0700, Matthew Wilcox wrote: > 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. I like this idea too. -- Kirill A. Shutemov