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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham 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 76FA1C3F68F for ; Fri, 14 Feb 2020 22:27:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3591E2082F for ; Fri, 14 Feb 2020 22:27:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3591E2082F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=de.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CEE966B06AE; Fri, 14 Feb 2020 17:27:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C9E906B06AF; Fri, 14 Feb 2020 17:27:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDBCC6B06B0; Fri, 14 Feb 2020 17:27:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id A5CD06B06AE for ; Fri, 14 Feb 2020 17:27:45 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 41B334DC4 for ; Fri, 14 Feb 2020 22:27:45 +0000 (UTC) X-FDA: 76490170890.09.oil69_268575ac21737 X-HE-Tag: oil69_268575ac21737 X-Filterd-Recvd-Size: 6531 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Feb 2020 22:27:44 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01EMOQwt140482; Fri, 14 Feb 2020 17:27:42 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y4j897ny6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Feb 2020 17:27:41 -0500 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 01EMQPA0144752; Fri, 14 Feb 2020 17:27:41 -0500 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y4j897nxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Feb 2020 17:27:41 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01EMRBsq019920; Fri, 14 Feb 2020 22:27:40 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma04dal.us.ibm.com with ESMTP id 2y5bc0cd9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Feb 2020 22:27:40 +0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01EMRb6B57540952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Feb 2020 22:27:37 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47335136093; Fri, 14 Feb 2020 22:27:37 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A879136091; Fri, 14 Feb 2020 22:27:36 +0000 (GMT) Received: from localhost.localdomain (unknown [9.114.17.106]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 14 Feb 2020 22:27:36 +0000 (GMT) From: Christian Borntraeger To: Christian Borntraeger , Janosch Frank , Andrew Morton Cc: KVM , Cornelia Huck , David Hildenbrand , Thomas Huth , Ulrich Weigand , Claudio Imbrenda , linux-s390 , Michael Mueller , Vasily Gorbik , Andrea Arcangeli , linux-mm@kvack.org, Will Deacon , Sean Christopherson Subject: [PATCH v2 39/42] example for future extension: mm:gup/writeback: add callbacks for inaccessible pages: error cases Date: Fri, 14 Feb 2020 17:26:55 -0500 Message-Id: <20200214222658.12946-40-borntraeger@de.ibm.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200214222658.12946-1-borntraeger@de.ibm.com> References: <20200214222658.12946-1-borntraeger@de.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-14_08:2020-02-14,2020-02-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=942 impostorscore=0 priorityscore=1501 spamscore=0 adultscore=0 mlxscore=0 malwarescore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002140165 Content-Transfer-Encoding: quoted-printable 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: From: Claudio Imbrenda This is a potential extension to do error handling if we fail to make the page accessible if we know what others need. Signed-off-by: Claudio Imbrenda --- mm/gup.c | 17 ++++++++++++----- mm/page-writeback.c | 6 +++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a1c15d029f7c..354bcfbd844b 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -193,6 +193,7 @@ static struct page *follow_page_pte(struct vm_area_st= ruct *vma, struct page *page; spinlock_t *ptl; pte_t *ptep, pte; + int ret; =20 /* FOLL_GET and FOLL_PIN are mutually exclusive. */ if (WARN_ON_ONCE((flags & (FOLL_PIN | FOLL_GET)) =3D=3D @@ -250,8 +251,6 @@ static struct page *follow_page_pte(struct vm_area_st= ruct *vma, if (is_zero_pfn(pte_pfn(pte))) { page =3D pte_page(pte); } else { - int ret; - ret =3D follow_pfn_pte(vma, address, ptep, flags); page =3D ERR_PTR(ret); goto out; @@ -259,7 +258,6 @@ static struct page *follow_page_pte(struct vm_area_st= ruct *vma, } =20 if (flags & FOLL_SPLIT && PageTransCompound(page)) { - int ret; get_page(page); pte_unmap_unlock(ptep, ptl); lock_page(page); @@ -276,7 +274,12 @@ static struct page *follow_page_pte(struct vm_area_s= truct *vma, page =3D ERR_PTR(-ENOMEM); goto out; } - arch_make_page_accessible(page); + ret =3D arch_make_page_accessible(page); + if (ret) { + put_page(page); + page =3D ERR_PTR(ret); + goto out; + } } if (flags & FOLL_TOUCH) { if ((flags & FOLL_WRITE) && @@ -1920,7 +1923,11 @@ static int gup_pte_range(pmd_t pmd, unsigned long = addr, unsigned long end, =20 VM_BUG_ON_PAGE(compound_head(page) !=3D head, page); =20 - arch_make_page_accessible(page); + ret =3D arch_make_page_accessible(page); + if (ret) { + put_page(head); + goto pte_unmap; + } SetPageReferenced(page); pages[*nr] =3D page; (*nr)++; diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 4c020e4ae71c..558d7063c117 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2807,7 +2807,11 @@ int __test_set_page_writeback(struct page *page, b= ool keep_write) inc_zone_page_state(page, NR_ZONE_WRITE_PENDING); } unlock_page_memcg(page); - arch_make_page_accessible(page); + /* + * If writeback has been triggered on a page that cannot be made + * accessible, it is too late. + */ + WARN_ON(arch_make_page_accessible(page)); return ret; =20 } --=20 2.25.0