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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 45CA0C31E45 for ; Thu, 13 Jun 2019 15:25:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1120D206BB for ; Thu, 13 Jun 2019 15:25:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="AwqPgJ4i"; dkim=pass (1024-bit key) header.d=fb.onmicrosoft.com header.i=@fb.onmicrosoft.com header.b="ZNz2GTn4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388656AbfFMPZd (ORCPT ); Thu, 13 Jun 2019 11:25:33 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:58174 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732020AbfFMPZa (ORCPT ); Thu, 13 Jun 2019 11:25:30 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5DFGUqo030339; Thu, 13 Jun 2019 08:24:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=5upTGPFsqkaNgj1lgYq0xrYnDw/z1eQKH2p21LD4RJw=; b=AwqPgJ4ittIgsIWi/jCa/WQ6GEnwl0Y6g95/jk5rdPePOTM5EBBdUrPaOFH/toZo4bRr gqUGU6T0BuCQd2+DA6Z2wEe4fZJGhfepLcjEgXEVXpomQplmEsUq6Z+JNYuc4tb7I5gS sqRPvBrXzEvJ1m32q+RLIfwQzW7DLP1mrG8= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 2t3qmj0bex-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2019 08:24:07 -0700 Received: from prn-hub02.TheFacebook.com (2620:10d:c081:35::126) by prn-hub02.TheFacebook.com (2620:10d:c081:35::126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Thu, 13 Jun 2019 08:24:05 -0700 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5 via Frontend Transport; Thu, 13 Jun 2019 08:24:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5upTGPFsqkaNgj1lgYq0xrYnDw/z1eQKH2p21LD4RJw=; b=ZNz2GTn4OWPcEoVSxI95MdoYpFe7F1h3iDHQsMXVGL+aeVtinsJg6Xa0UxDsK1yaSHfCY6wO9PES+QaC4ctni7WoXg/7TUVEJ1QQFN/+OFOlOtnNcU/TzOimTITl5wC/jDky4mQK8Bec05OaY+nwFXu78Bii7B93Gen1hnfDhGY= Received: from MWHPR15MB1165.namprd15.prod.outlook.com (10.175.3.22) by MWHPR15MB1437.namprd15.prod.outlook.com (10.173.234.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Thu, 13 Jun 2019 15:24:04 +0000 Received: from MWHPR15MB1165.namprd15.prod.outlook.com ([fe80::400e:e329:ea98:aa0d]) by MWHPR15MB1165.namprd15.prod.outlook.com ([fe80::400e:e329:ea98:aa0d%6]) with mapi id 15.20.1987.012; Thu, 13 Jun 2019 15:24:04 +0000 From: Song Liu To: "Kirill A. Shutemov" CC: "Kirill A. Shutemov" , LKML , "linux-mm@kvack.org" , "namit@vmware.com" , "peterz@infradead.org" , "oleg@redhat.com" , "rostedt@goodmis.org" , "mhiramat@kernel.org" , "matthew.wilcox@oracle.com" , Kernel Team Subject: Re: [PATCH v3 3/5] mm, thp: introduce FOLL_SPLIT_PMD Thread-Topic: [PATCH v3 3/5] mm, thp: introduce FOLL_SPLIT_PMD Thread-Index: AQHVIWtWTe7ps5z8rEO6sAR2s+F9WKaZjDkAgAAQ0ICAAAU/gIAADRAAgAADJ4CAAAK6gA== Date: Thu, 13 Jun 2019 15:24:04 +0000 Message-ID: References: <20190612220320.2223898-1-songliubraving@fb.com> <20190612220320.2223898-4-songliubraving@fb.com> <20190613125718.tgplv5iqkbfhn6vh@box> <5A80A2B9-51C3-49C4-97B6-33889CC47F08@fb.com> <20190613141615.yvmckzi3fac4qjag@box> <32E15B93-24B9-4DBB-BDD4-DDD8537C7CE0@fb.com> <20190613151417.7cjxwudjssl5h2pf@black.fi.intel.com> In-Reply-To: <20190613151417.7cjxwudjssl5h2pf@black.fi.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3445.104.11) x-originating-ip: [2620:10d:c090:180::1:7078] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 20555ca9-9841-49a8-4261-08d6f0132bbf x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:MWHPR15MB1437; x-ms-traffictypediagnostic: MWHPR15MB1437: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 0067A8BA2A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(39860400002)(346002)(376002)(366004)(396003)(189003)(199004)(7416002)(5660300002)(6506007)(53546011)(102836004)(46003)(6512007)(476003)(11346002)(446003)(2616005)(53936002)(68736007)(2906002)(99286004)(186003)(6436002)(6916009)(76176011)(229853002)(6116002)(33656002)(57306001)(486006)(54906003)(14454004)(86362001)(25786009)(36756003)(71190400001)(71200400001)(4326008)(305945005)(7736002)(76116006)(478600001)(8676002)(6246003)(6486002)(316002)(8936002)(81166006)(81156014)(50226002)(66446008)(64756008)(66556008)(14444005)(66946007)(66476007)(256004)(73956011);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR15MB1437;H:MWHPR15MB1165.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: cVUdMAju7C9HoBdVDE96XRFUhLjLOi/CYsB5I9Jp2s9PviHT+OYET71zA6Il/qKewnZeUsXHkaGQXF4U4nMebQWanRYAwuTPPzFg0FjeQeRaChFBBPAlJ8iY23kLuELglK5Y44gEsNICydcAAlBlJE9dExDqE4fvelL/6qN6dj8PjgsG8qwPf4tDeR72ouQZNRaHya0hB030khe8r7407tq8VoRT1N6f+AyUclmyY+GCTyr4tGXAKQUSw4cWISPgyF8MxAxxgQx75fxqxh5zE+Vz/rtblzEa8vw/WT3IsEvQyKiLi2qdbwl4BKJ07/7N3IZllsoJQFkQNeXrrwhjZWyZAY6YuX5YGwWv0uvwzHXflmDjANxMfUy6rHIAwRPN3jdMHdvR2z4l+DgmcBhNY9wbsIbso9N7Nho68QGYlUE= Content-Type: text/plain; charset="us-ascii" Content-ID: <0D44160B39BFE9428279B658D1C56286@namprd15.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 20555ca9-9841-49a8-4261-08d6f0132bbf X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2019 15:24:04.7122 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: songliubraving@fb.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1437 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-13_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906130114 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jun 13, 2019, at 8:14 AM, Kirill A. Shutemov wrote: >=20 > On Thu, Jun 13, 2019 at 03:03:01PM +0000, Song Liu wrote: >>=20 >>=20 >>> On Jun 13, 2019, at 7:16 AM, Kirill A. Shutemov = wrote: >>>=20 >>> On Thu, Jun 13, 2019 at 01:57:30PM +0000, Song Liu wrote: >>>>> And I'm not convinced that it belongs here at all. User requested PMD >>>>> split and it is done after split_huge_pmd(). The rest can be handled = by >>>>> the caller as needed. >>>>=20 >>>> I put this part here because split_huge_pmd() for file-backed THP is >>>> not really done after split_huge_pmd(). And I would like it done befor= e >>>> calling follow_page_pte() below. Maybe we can still do them here, just= =20 >>>> for file-backed THPs? >>>>=20 >>>> If we would move it, shall we move to callers of follow_page_mask()?=20 >>>> In that case, we will probably end up with similar code in two places: >>>> __get_user_pages() and follow_page().=20 >>>>=20 >>>> Did I get this right? >>>=20 >>> Would it be enough to replace pte_offset_map_lock() in follow_page_pte(= ) >>> with pte_alloc_map_lock()? >>=20 >> This is similar to my previous version: >>=20 >> + } else { /* flags & FOLL_SPLIT_PMD */ >> + pte_t *pte; >> + spin_unlock(ptl); >> + split_huge_pmd(vma, pmd, address); >> + pte =3D get_locked_pte(mm, address, &ptl); >> + if (!pte) >> + return no_page_table(vma, flags); >> + spin_unlock(ptl); >> + ret =3D 0; >> + } >>=20 >> I think this is cleaner than use pte_alloc_map_lock() in follow_page_pte= ().=20 >> What's your thought on these two versions (^^^ vs. pte_alloc_map_lock)? >=20 > It's additional lock-unlock cycle and few more lines of code... >=20 >>> This will leave bunch not populated PTE entries, but it is fine: they w= ill >>> be populated on the next access to them. >>=20 >> We need to handle page fault during next access, right? Since we already >> allocated everything, we can just populate the PTE entries and saves a >> lot of page faults (assuming we will access them later).=20 >=20 > Not a lot due to faultaround and they may never happen, but you need to > tear down the mapping any way. I see. Let me try this way.=20 Thanks, Song >=20 > --=20 > Kirill A. Shutemov