Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp793552ybf; Fri, 28 Feb 2020 07:45:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxfxKPQ+xV53/5lg3yXnjgltLRkV920wtGi2fUCVkhf8I2NwYuG9+u0CvJ2YBBnijVt/9/c X-Received: by 2002:a05:6830:18f1:: with SMTP id d17mr3771113otf.303.1582904741675; Fri, 28 Feb 2020 07:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582904741; cv=none; d=google.com; s=arc-20160816; b=H1QShUilURwzBmfMQjNqm+oKQ8qIYK5v7q97yClo6Pg0fmQtbd/z1fi2PSxh5ynWFq Utm5HFAKG2dzJwpNlFbp5lY48NF+CBWD7+eMygLV0brphyYXZki1V9EMKgjzNmXJTwUY ARGsCE+p33r2pIZgzH+9am5oTdK3DO7qFT0J0sHB9hHDxEvvUC1022xIc0lFoMSUDcyN 61if9Fk1A3gJPpblvxgoY05wYGEZ0RiYMGsz1GGcINNAq0shOkmQkl5uERptrBXhj64K X/06Hs/75HYKI72QGMjsE+5Mi/VPdsczlRunbmbH5sIRBR1q39+5vRcIrpVJVxAgz52W fGkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=kYJm8AO499ZI6oYrJCvPJKTb1madAFisR9+pmUlKBbg=; b=j7IvCI1Xa/JNR8h6Yaof1nQSANe3yj6OzPLvQhl36Eb6UggT9KBEkbPmlBFPi2eP1j c/Ru17kchH7ZJTzzK0A3SYZ6SVKyVBTpqDqMZChLvmR9VrBQ/1U5G+l+tjU9giZjdXY1 xEbQCgzoRUUqmXNXtUD1HVqcnNOJtC9HAwwNat18Femt5jPbUWwbHqxqaip0pg24pRoX nFzYUTYqhtezZ//6tQWEqIl1fIrn3kFOj+zwYqKXc7N9mjmPSbx2tulIID9Y3gn+vYAG CrsET5nmZ4/tqUUaEPpAHKIpKGXKU+hL2aFpiTztSzgTWT6aXPhrJN6x8ie7bs42vpKi VMdw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l198si2179219oig.120.2020.02.28.07.45.29; Fri, 28 Feb 2020 07:45:41 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbgB1PoY (ORCPT + 99 others); Fri, 28 Feb 2020 10:44:24 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50834 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726974AbgB1PoX (ORCPT ); Fri, 28 Feb 2020 10:44:23 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01SFcc2Q118486 for ; Fri, 28 Feb 2020 10:44:23 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yepy3ry7d-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Feb 2020 10:43:32 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Feb 2020 15:43:30 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 28 Feb 2020 15:43:27 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01SFhQnW52101170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Feb 2020 15:43:26 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 157BBAE04D; Fri, 28 Feb 2020 15:43:26 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BA2FAE056; Fri, 28 Feb 2020 15:43:25 +0000 (GMT) Received: from p-imbrenda.emea.ibm.com (unknown [9.145.11.131]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Feb 2020 15:43:25 +0000 (GMT) From: Claudio Imbrenda To: linux-next@vger.kernel.org, akpm@linux-foundation.org Cc: borntraeger@de.ibm.com, david@redhat.com, aarcange@redhat.com, linux-mm@kvack.org, frankja@linux.ibm.com, sfr@canb.auug.org.au, jhubbard@nvidia.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [RFC v1 1/2] mm/gup: fixup for 9947ea2c1e608e32 "mm/gup: track FOLL_PIN pages" Date: Fri, 28 Feb 2020 16:43:21 +0100 X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200228154322.329228-1-imbrenda@linux.ibm.com> References: <20200228154322.329228-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 20022815-0012-0000-0000-0000038B3507 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022815-0013-0000-0000-000021C7E25A Message-Id: <20200228154322.329228-3-imbrenda@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-28_04:2020-02-28,2020-02-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 mlxlogscore=830 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002280124 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case pin fails, we need to unpin, a simple put_page will not be enough Signed-off-by: Claudio Imbrenda --- mm/gup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/gup.c b/mm/gup.c index f589299b0d4a..0b9a806898f3 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2134,7 +2134,10 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, goto pte_unmap; if (unlikely(pte_val(pte) != pte_val(*ptep))) { - put_page(head); + if (flags & FOLL_GET) + put_page(head); + else if (flags & FOLL_PIN) + unpin_user_page(head); goto pte_unmap; } -- 2.24.1