Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1758681ybg; Sat, 19 Oct 2019 01:55:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0PNIohoiJempkoVTKFjE1cvB2l68H4i2LdwKGpyIrBn/wFcgETrX6lglAdpPBxhZ5mH0I X-Received: by 2002:a50:f701:: with SMTP id g1mr13994562edn.62.1571475305826; Sat, 19 Oct 2019 01:55:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1571475305; cv=pass; d=google.com; s=arc-20160816; b=OOUtiLpAIdE+MuT1A6QrRmoBIx8Olfpo/Tq+GVdtziUbzRigZkjkYoVzKnHGlfbYHy ZWRBb9RroDECwPYQujYILT/nVwSpRhq/Gt8kbPr6mgXdV1fMxoqsPzGt1Fm/NwQYmnpP N+pqTsXLh+8IjSNEpcy0omnSRlzbFfjn5E714Dnv7bFlsDWJtuGZ630HeC74jCUNsBew 1XfSgV3adviBc1rZFarU3qGPqAVYB9mXJ7zySJH8nZ7K2xjbw/liq7Rx5DF3L4X8lL2A UUHS4OKTmAxsMxdo6NmdgXOur7AWIbgyA59jW5Bu81nXDxuYqNQRDbJ4qhtTjoM7aRJm Xxow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature:dkim-signature; bh=Tk2U34DE0PIYArCIK172NEMrbXVLFZYYIjfVWo2skGA=; b=Adz7zetauMk2KG2Zp6i40jVwM1K7Iocxwg7JL4umw6h2AdepHiiquReqjXz1/VVIwl a6JHip4yZVZxJLn4G2q6z4FQqZL9+/E+HJ8fNEZ5iUeVuAtZzHKIOZepJ6ZEqdWJMCTW opgONkX8S6MjPwLjfKh3Y9s2e7Y/qNgTd83icFdqGK/YX+jsDsJQPPtRWjDrheNBYPGa rL9Rh2ee9KvjEIr3Ij9JA2BaRfw1xqg5Op9W9w3FY4gSM0IaAaMjlf4geQWIH9JTZBIG FAeYo8cYhIv7AEgzuT8FWWq6kC5WFI+Fre7MVp2kZoTNbimmxoEG1B/yt08HwbEtSSaB /6VQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Oe3vX2NE; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector2-fb-onmicrosoft-com header.b=QkGjm1Ce; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.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=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si252499eda.268.2019.10.19.01.54.42; Sat, 19 Oct 2019 01:55:05 -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=@fb.com header.s=facebook header.b=Oe3vX2NE; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector2-fb-onmicrosoft-com header.b=QkGjm1Ce; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.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=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2505473AbfJRR12 (ORCPT + 99 others); Fri, 18 Oct 2019 13:27:28 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:42142 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2634465AbfJRR11 (ORCPT ); Fri, 18 Oct 2019 13:27:27 -0400 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9IHJKk7025812; Fri, 18 Oct 2019 10:27:15 -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=Tk2U34DE0PIYArCIK172NEMrbXVLFZYYIjfVWo2skGA=; b=Oe3vX2NEJ/R9wJleWUUbOE0E/5aUDdGcZNmuKwJti0/5lDwsEWz9qZ1gHl5ySm/ONjo4 sw29p50Iq8b5tZ376yDjjQefBHKnCxrhWwmnomFyb9963voV5qMEG0qqn8SUAQFrMW3C UGQDDPWEMzXyiJB/UwdnCemKk+xxv+PjfQI= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2vqguv89sp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 18 Oct 2019 10:27:15 -0700 Received: from prn-hub05.TheFacebook.com (2620:10d:c081:35::129) by prn-hub01.TheFacebook.com (2620:10d:c081:35::125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Fri, 18 Oct 2019 10:27:13 -0700 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5 via Frontend Transport; Fri, 18 Oct 2019 10:27:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eEHy6z0bSrfnGKLN2ZcZBNEg3NaUFmpxg6TGJdSzLC+Byl88UYzQxDrJbOUe5/jHEHp48cMk8+1AOTW9um/YLAPwenjcNSQGT9XQa296a79qIzRIcHpa3C2ku74v1xl6jb8JTMFHwFBLvoAIsb6qi7WGo6LB1rl//VK6x9hsQ2j2W04i4AhU1Bndzuii8TkMP4WZGw01ErGcQho9DJaU/GffuyR0Tapn6ZVuPj6vhdDwtaP3MEemAZ6XlQlfi7Cd7XVjtyD15h/8prJZgCtIltrdhsWTQsWluYRuJR9xmJFvTMTnFfL10s69aDHg9GOkQw1KJCYjO3YaWuhHCyHhXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tk2U34DE0PIYArCIK172NEMrbXVLFZYYIjfVWo2skGA=; b=CyZTfJkepndYCAhEr7Ia8OgrQxSHVwSHAdgRD8DtyUkeWUTSl2uEUg7NhLuwyljI9FeIaeT2VvNx8hIfCpHWqOH1dtcWsLXt4XwRMXSca+6QVkGNvGx2/gD32DWO/HGcasbhrYsdNFT1aURqAUgkvnO37FcETiUppnmzEH+uPbrSPj7F8lUXrHbvkgFAnvqPQV3v/bfaBGFVElPjdSiuG9N5qHSgf6yXK2Yi8fJ6evAK/qijCdHv4qry+eAjXH+bq3jXNC3dE4BxV62Usf4J7o+VY+Qcw7OrNkxOEQ/jGKB9h8ZFUDpCoKzfjZZj55GCAhaGNTWfHgZzpKVKttdl3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fb.com; dmarc=pass action=none header.from=fb.com; dkim=pass header.d=fb.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector2-fb-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tk2U34DE0PIYArCIK172NEMrbXVLFZYYIjfVWo2skGA=; b=QkGjm1CewT3G51+J/yFPwWI4aERueCBV3SU0puo25D2Nn1CPYmtx6DRfw0DdTEnWGZk8zrCnNtpRr199KCFOz1FjaY4NzVk92b7e1Oxd7TSMR9VaECB6nIm1z1H5bnr4pJRz3gENZmGGS7VH13o3Ye/HsbgMIuSleVW1ZbCuZhY= Received: from MWHPR15MB1165.namprd15.prod.outlook.com (10.175.3.22) by MWHPR15MB1422.namprd15.prod.outlook.com (10.173.234.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.16; Fri, 18 Oct 2019 17:27:12 +0000 Received: from MWHPR15MB1165.namprd15.prod.outlook.com ([fe80::fdc8:5546:bace:15f5]) by MWHPR15MB1165.namprd15.prod.outlook.com ([fe80::fdc8:5546:bace:15f5%5]) with mapi id 15.20.2367.019; Fri, 18 Oct 2019 17:27:12 +0000 From: Song Liu To: Johannes Weiner CC: open list , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "matthew.wilcox@oracle.com" , Kernel Team , "william.kucharski@oracle.com" , "kirill.shutemov@linux.intel.com" , "Hugh Dickins" Subject: Re: [PATCH v2] mm,thp: recheck each page before collapsing file THP Thread-Topic: [PATCH v2] mm,thp: recheck each page before collapsing file THP Thread-Index: AQHVhdJpENZJXtqpok2fOupB1uQ0i6dgnG+AgAAChQCAAAf0AA== Date: Fri, 18 Oct 2019 17:27:12 +0000 Message-ID: <696F8683-9A4B-4CD7-A96A-1E68E6A92E02@fb.com> References: <20191018163754.3736610-1-songliubraving@fb.com> <20191018164943.GA179426@cmpxchg.org> <20191018165844.GB179426@cmpxchg.org> In-Reply-To: <20191018165844.GB179426@cmpxchg.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3594.4.19) x-originating-ip: [2620:10d:c090:200::d133] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 77fa8f69-2a35-4ad6-41c7-08d753f069c6 x-ms-traffictypediagnostic: MWHPR15MB1422: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; x-forefront-prvs: 01949FE337 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(366004)(346002)(376002)(396003)(39860400002)(189003)(199004)(478600001)(476003)(81166006)(316002)(99286004)(66946007)(86362001)(256004)(66476007)(6486002)(2906002)(6436002)(14444005)(36756003)(486006)(8676002)(14454004)(81156014)(33656002)(5660300002)(2616005)(11346002)(76116006)(66556008)(64756008)(66446008)(71200400001)(71190400001)(25786009)(50226002)(6506007)(53546011)(305945005)(4326008)(7736002)(54906003)(446003)(6916009)(46003)(6512007)(186003)(229853002)(6246003)(76176011)(102836004)(8936002)(6116002)(142933001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR15MB1422;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: BCL:0; x-microsoft-antispam-message-info: ayOKAumH0bWePmPxLpYXMkHGxEM3M+gV/qbcb20r7jrplXhoQgDRdfoJVzuH7lUfwRXLJranwzqrNH1JnHXwQx++2GBggt8mUJWqxJbzfwkO34s5oMSr8p0BioLp7XzZ/DJc2tgtHKy6HnvLw790Dq90C+4H2kIcRPQcSfLtw7NRXvu05Rbc/vwQxpiHRjGtPwSqdBBW406pHjP6bX0Z9Wv24rYHff+Gt45/8IqkKGpapYgw8GUzw6cucWCjiVQ91pVzcmgJfPjrel55TRny0/Rt34TPOv9ICRw1WRxoQ3UwWU7wHHxlrAY57ETQV056xxNYWCJ5QeoDgAtGxtXNPGr0nmu5V/imxmyLX1tETOgdUVTZUgpwy+fc/98vE7y3tf07imt2yytzOYm9X6AvM+w7sudH/NnsVSArLJyx6xw= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 77fa8f69-2a35-4ad6-41c7-08d753f069c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Oct 2019 17:27:12.6792 (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: NBUSQRMkfdrg4AqKiVJ6WqVt07Z8YX9zIyzQ5eVtA7gpk6S8SiXj9ZlZ1HX9c9DaKbzIc1h9VHf6mqz5ECbuag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1422 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-18_04:2019-10-18,2019-10-18 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxscore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 bulkscore=0 adultscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910180158 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Oct 18, 2019, at 9:58 AM, Johannes Weiner wrote: >=20 > On Fri, Oct 18, 2019 at 12:49:46PM -0400, Johannes Weiner wrote: >> On Fri, Oct 18, 2019 at 09:37:54AM -0700, Song Liu wrote: >>> In collapse_file(), after locking the page, it is necessary to recheck >>> that the page is up-to-date. Add PageUptodate() check for both shmem TH= P >>> and file THP. >>>=20 >>> Current khugepaged should not try to collapse dirty file THP, because i= t >>> is limited to read only text. Add a PageDirty check and warning for fil= e >>> THP. This is added after page_mapping() check, because if the page is >>> truncated, it might be dirty. >>>=20 >>> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem)= FS") >>> Cc: Kirill A. Shutemov >>> Cc: Johannes Weiner >>> Cc: Hugh Dickins >>> Cc: William Kucharski >>> Cc: Andrew Morton >>> Signed-off-by: Song Liu >>=20 >> Acked-by: Johannes Weiner >=20 > We should also be able to remove the unlocked tests for those two > conditions, right? Yeah, I think we can remove them.=20 Thanks, Song >=20 > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > index 0a1b4b484ac5..a3ef6ce86bfa 100644 > --- a/mm/khugepaged.c > +++ b/mm/khugepaged.c > @@ -1601,17 +1601,6 @@ static void collapse_file(struct mm_struct *mm, > result =3D SCAN_FAIL; > goto xa_unlocked; > } > - } else if (!PageUptodate(page)) { > - xas_unlock_irq(&xas); > - wait_on_page_locked(page); > - if (!trylock_page(page)) { > - result =3D SCAN_PAGE_LOCK; > - goto xa_unlocked; > - } > - get_page(page); > - } else if (PageDirty(page)) { > - result =3D SCAN_FAIL; > - goto xa_locked; > } else if (trylock_page(page)) { > get_page(page); > xas_unlock_irq(&xas);