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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59F08C433F5 for ; Tue, 16 Nov 2021 02:47:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 051DA6187F for ; Tue, 16 Nov 2021 02:47:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 051DA6187F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 8C2CA6B00BD; Mon, 15 Nov 2021 21:47:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 849366B00BE; Mon, 15 Nov 2021 21:47:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C3646B00BF; Mon, 15 Nov 2021 21:47:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 5D2656B00BD for ; Mon, 15 Nov 2021 21:47:08 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2D6D2852E4 for ; Tue, 16 Nov 2021 02:47:08 +0000 (UTC) X-FDA: 78813256536.24.9D095A5 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf24.hostedemail.com (Postfix) with ESMTP id C0F7CB0000B1 for ; Tue, 16 Nov 2021 02:47:06 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AFNEKRI013362 for ; Tue, 16 Nov 2021 02:47:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=to : cc : subject : from : message-id : date : content-type : content-transfer-encoding : mime-version; s=pp1; bh=fC4njs+d6RlWalJTSv5sBOoA19pkO4CblIbWtJyDIJY=; b=krGQtXOjiNQ/R11tZkF7QNHvU74U+PXm42654yfTq9MCZA9IQEyNzNqbzVCiw5VauHOe g76c9RbDq/QYHoGy+fDmuYJE4X2SAUpOEuDis96Ntq2TiXjBFMaN/sL398NFoX0tUegG Pe/twtyorvGMlDPxC6iBpgpo1+7BLRLOEsNgAzE8V4NpXkq2H4++0790hcnUoe7YEXqD zvE37BCdoZZJA8D0eNJLjYrdCgKA+gHTyM7yOjfUORzxTJgtgtDVtrzxKBs3YmbTvCRK HXXLp+zQipyaXYtc5L7n364QtbcvhNC2eb+Ojm0Le5uzo+0FwBvol0hvbs//bhgei3k3 pQ== 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 3cc122b2fa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 16 Nov 2021 02:47:05 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1AG2buW0001016 for ; Tue, 16 Nov 2021 02:47:04 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma04dal.us.ibm.com with ESMTP id 3ca50anfh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 16 Nov 2021 02:47:04 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1AG2l3to55116260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Nov 2021 02:47:03 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5123C2805E; Tue, 16 Nov 2021 02:47:03 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3489F28058; Tue, 16 Nov 2021 02:47:03 +0000 (GMT) Received: from mww0141.wdc07m.mail.ibm.com (unknown [9.208.70.161]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTPS; Tue, 16 Nov 2021 02:47:03 +0000 (GMT) To: linux-mm@kvack.org Cc: "Aniket Kulkarni" , "Pawan Powar" , "Rajshekar Iyer" , ask@linux.vnet.ibm.com Subject: Question regarding map count for compound pages From: "Harish Mara" Message-ID: Date: Mon, 15 Nov 2021 22:47:01 -0400 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-KeepSent: 77A59952:F23E0FCF-0025878F:000F1EF4; name=$KeepSent; type=4 X-Mailer: HCL Notes Build V1101FP3_03312021 SHF15 May 21, 2021 X-Disclaimed: 55343 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dwwWu1KjzYIFkmEC3diUkbJc-4k_DGeE X-Proofpoint-ORIG-GUID: dwwWu1KjzYIFkmEC3diUkbJc-4k_DGeE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-15_16,2021-11-15_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=901 suspectscore=0 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 phishscore=0 clxscore=1011 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111160010 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C0F7CB0000B1 X-Stat-Signature: wmmy4bp1rihthkxnmi3dm1q9az91yqra Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=krGQtXOj; spf=pass (imf24.hostedemail.com: domain of Harish.Mara@ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=Harish.Mara@ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-HE-Tag: 1637030826-159129 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: Background: On older kernel?s, we could have our device driver create char devices and = implement file=5Foperations and vm=5Foperations for open, release, mmap, fa= ult=20 etc. The driver allocates memory (128KB, order 5) as compound pages. The user application would then map/mmap these device files to perform=20 read/write operations. On recent kernels, this creates problems when the user space maps multiple = 128KB chunks that exceed 2MB. This would sometime result in bad page=20 getting mapped to the user space process. Almost always we see ?Bad page=20 map? errors during munmap because the map count is going below 0. It looks like the culprit is zap=5Fpte=5Frange(), which calls=20 page=5Fremove=5Frmap() with the compound=5Fflag =3D false. As a result, ins= tead of=20 decrementing the compound=5Fmapcount for the page the page->=5Fmapcount is = decremented causing a lot of bad page errors. Questions: Is this the right usage of compound pages? I.e can I allocate compound=20 pages in my kernel driver to be mapped to char device file by a user=20 process? If yes, then why does it fail on latest kernel when the mmap-ed size=20 exceeds 2MB? If no, why was it working on the older kernels? If it worked then,=20 shouldn?t it work now? What is special about map size being greater than 2MB to trigger this? Should compound pages be used for Anonymous purposes only?