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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEEE2C433FE for ; Wed, 12 Oct 2022 19:01:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E98D900002; Wed, 12 Oct 2022 15:01:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3996B6B0073; Wed, 12 Oct 2022 15:01:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C3CB900002; Wed, 12 Oct 2022 15:01:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 081706B0071 for ; Wed, 12 Oct 2022 15:01:55 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B532816113A for ; Wed, 12 Oct 2022 19:01:54 +0000 (UTC) X-FDA: 80013216948.04.BB555C7 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf27.hostedemail.com (Postfix) with ESMTP id 1EBFE40025 for ; Wed, 12 Oct 2022 19:01:53 +0000 (UTC) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29CGZp6j008404; Wed, 12 Oct 2022 12:01:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=s2048-2021-q4; bh=g1ELcvrprxkFZskJoh7K/MQP35fAERgJDHE+QM6hj/k=; b=OUWaE8igUK7udZf5wk7lQ3FWQiZHRdwOYfU7YL7eDRCOR/lsy5bHjqlqiCipXk+o94xl lf9XnIkGuW9gtoGzFu8847pV6Y9qbJyoBV5lUnALRGb/znntpOnvv4YVYRqVtVF+0dFR 6g2z5yCSfk+IU7Msl+TaGmmow9v6lzPFpiybjdpCze3UtwqvnwUxc2sn8GM3TvGzqAgz GIgVTd8AAevky+EDBymf0dLi7YkdoeQ5j3P+KYecfmWZlTKk2oEOtHmWUyBQnNvhcESd a594cIS7e5oKMeuazE+u0NspyDLb9O0yAtdasHY2Qx/VopXxJT3DiUrs36NfytpTVOrG cg== Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2042.outbound.protection.outlook.com [104.47.56.42]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3k5qgr5wwv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Oct 2022 12:01:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=adXKflTJ77Yl8qy2k9XGemQd3wc4kJxyZUzZGs4xa9F3pI6A2kdDuKctaZgCdSrSzAcoXBbNriTeHDr431D2HYF/O/0Oy1+8FjI2MWJXNEvZlsbcLkECpz/QfkGUvCHKRm10I5wLzWkZ8idRF1ZJthnHiAE5eGK5ao93/5OZ0KWU1FP2Mp2Z/9n7p536A+Dcy4anLLKzsYh3L7mukmcuQW1v6Hs3YE0FXiJu3060qhRGf4a+JSphpvSv+CNkavgYAVweGbgKrpE/niGYWrG4KX1+QgLoZq/swab7xCF77PZ5JG7+nH9GyCqE5ZySop9dmuef4ESkrnXSspxf5j2dDw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g1ELcvrprxkFZskJoh7K/MQP35fAERgJDHE+QM6hj/k=; b=JNpf5fC3l1YN+Wk/i1DZ2h4oYKJdNq1QyX9YlkwmxsJbYXm77HT51vtKoDJAK3RW0LTO2KB8qUSjillDxND6yagc5bCdHY0K1fc/2bPlhWQgiOAzPefQauB5fJZjHEILCIVWCvSWBOEVoCJZYHx8kcmU/yHTdE+EjCmwNCrVhoo+xa3tBvGRNNg0xGgaD6yDQw6OpH6voYoCq+FfANauKgmhNzYNcVhqrv+Tg9wB3Mcc0p0w0J0UPFfpgDUJbd9YcKZXmZyFuo6TVZMCAbtMsMYMV0PzhDoJDmxweO/DEifUE+0c+He4OTz2/NJKiW5AXDujoGdPmRbVKXcu5wbUcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=meta.com; dmarc=pass action=none header.from=meta.com; dkim=pass header.d=meta.com; arc=none Received: from SA1PR15MB5109.namprd15.prod.outlook.com (2603:10b6:806:1dc::10) by PH0PR15MB4829.namprd15.prod.outlook.com (2603:10b6:510:a6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.22; Wed, 12 Oct 2022 19:01:44 +0000 Received: from SA1PR15MB5109.namprd15.prod.outlook.com ([fe80::d70d:8cce:bb1:e537]) by SA1PR15MB5109.namprd15.prod.outlook.com ([fe80::d70d:8cce:bb1:e537%6]) with mapi id 15.20.5709.022; Wed, 12 Oct 2022 19:01:44 +0000 From: Song Liu To: "Edgecombe, Rick P" , Luis Chamberlain CC: Song Liu , "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , Kernel Team , "linux-mm@kvack.org" , "song@kernel.org" , "hch@lst.de" , "x86@kernel.org" , "akpm@linux-foundation.org" , "Hansen, Dave" , "urezki@gmail.com" Subject: Re: [RFC v2 4/4] vmalloc_exec: share a huge page with kernel text Thread-Topic: [RFC v2 4/4] vmalloc_exec: share a huge page with kernel text Thread-Index: AQHY2qb4/DleVypvfEGw7i865KJ5wq4H9+4AgAAKPACAABD6AIABU84AgABHRYCAAJX7gIAA2jQAgAAGboA= Date: Wed, 12 Oct 2022 19:01:44 +0000 Message-ID: <0209B426-E425-44C2-825C-8AAC59B5BB2D@fb.com> References: <20221007234315.2877365-1-song@kernel.org> <20221007234315.2877365-5-song@kernel.org> <3842f1e7cfdde4f848e164872f62c0c1da654fec.camel@intel.com> <2B66E2E7-7D32-418C-9DFD-1E17180300B4@fb.com> <99201f0c3509e1ea3d08a462beaaea9d60382cff.camel@intel.com> <0D4668C5-28C1-4846-9698-C5C05BC23F0B@fb.com> <6fb1ef25df1caa7206572f24a70da0c2f2714135.camel@intel.com> In-Reply-To: <6fb1ef25df1caa7206572f24a70da0c2f2714135.camel@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3696.120.41.1.1) x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR15MB5109:EE_|PH0PR15MB4829:EE_ x-ms-office365-filtering-correlation-id: c163f6a9-1e4d-431e-f032-08daac84346c x-fb-source: Internal x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Gqj9VFO5ZeAsrEfoK91jcESZFM5EGzqkvTULbh8/U/CDOlJEMfrHRKeFWm49jja+zi9Onjn68BxJ83lAJSn897ykmJ7ga4NvQSJGLlKuTP6dDbxCM7f8ISmOAOQZWESKGq0doT91QgS48NTboq6R+Fp0XWOgTo/RjuIHfXhlVHliVRwjh0KiJeO/qjmGQA+0EqOxGbcLt+t1lyHzhAR6QpQ8yOS4K2rDqC0TlKzrFdENdtqKNFCIXKThYvM8mGEbe/VVw0lJDK6WKXcXvauey5KOLAnKG/4sm52l/ahptOg1gnYJdsw7dqAc2WFQ9+5L+MZYfHZeOGt1EAU4H1y3kdxPWiyWbtRs4zd4aoO5O5cuKSkpeGd8JAMZkxH7cXUYgRyRCguGT0g15OTElZzcWUK8XJ0bUfC10DXUvwZEPqM5cy1Hgn72yZ0MB7ioRhcpAb81BBYNzB6GKeORthYH16NOJ7R9bgZg/xur8Ll5VKptG3ah4IcqOjwEqSw4jSbvfZbjBGmDer1s37jdWW/wgWqRiOUtLtHMF6+0MzcnqptboehYjsMbqS7J/NzZ9A767BPZbB5xyKnXYyIcYAUfvi4yL+Lwf5HsOVQ408eHoLJUgYsFkct1ctJ6JsDcK9iWRvYlQT3W/T+sgcOMAWmU/wgrnMgfdEXAzWjV233JaF4+RtDwGLPHHmbKP1Or9y3fUf16wyvA2HW22j8OXdQmZHTEprbw0KWUD7JnGIPQv086El7xx5VsESS77UxeqBlLCr7IbtlXpb1srpEPLLkzroyLhW3m/3py3I4ni9uAsxc= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR15MB5109.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(346002)(396003)(136003)(366004)(451199015)(53546011)(316002)(38100700002)(71200400001)(110136005)(66446008)(64756008)(4326008)(8676002)(91956017)(66556008)(76116006)(66476007)(66946007)(122000001)(86362001)(38070700005)(36756003)(33656002)(83380400001)(6512007)(9686003)(6506007)(54906003)(478600001)(6486002)(8936002)(4001150100001)(2906002)(186003)(41300700001)(5660300002)(7416002)(14583001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?kB8/jj++L/JILQdWscaT2DEhRp3zxoi7uBkRM7axTPAcYiHnBq37ntanlBc8?= =?us-ascii?Q?aYRcmzQZop/essYHsvtZT1xUaafIWSJXETCidm8q8C2pxfg7vqTGeLYMu4/D?= =?us-ascii?Q?fWBZKjBOKM8BvGweZrrSKM0K+yRnvd2s8g1Bo7tMxqJV5MJRm/JReUCocitH?= =?us-ascii?Q?yzBh44GqO9Ob6n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LgEPUFZYR?= =?us-ascii?Q?XwWY3MpRWsVgaa1q++Y37jvQC6W7rafm4003ew7j2OOXXFsscxBZB2LIEcjf?= =?us-ascii?Q?UOn+L01GjaCsdZAPXFEqSMwLdJQkNk0vNVWhEoH2IX7WlhxDryttGzH2gCwr?= =?us-ascii?Q?VkhYvKkGPi18AtMqT2lAGu85T9XoXBXesadTiIUNaKecUsmF0jD14XpcG51f?= =?us-ascii?Q?Xu0qrB5f3XlInmbzQKJSEFctmdIURMSCTQSiha4JvgGkKc+t1+NnTrJG47c7?= =?us-ascii?Q?E+TD3N+0Uf8np85F88hzjNGYxUdhNghHmHKLuYXelGG3t19THQuBvoR9vOBY?= =?us-ascii?Q?+tEFZq06sHMf78B2alzCYe920sZH71mkSAdGmxNITOYzz9NrUeEfUC8XRIBe?= =?us-ascii?Q?lW6kGNjYd1uI0kmTCWus4eraL3vcX91Auys3Qk7v+uyGJlP6fLJU/syOaiUy?= =?us-ascii?Q?siPAXGC0nEDYMkaH+KB0LyMVEhDoZ4Cq1wbQYfkgPckivH32rX3rKxAwsFj4?= =?us-ascii?Q?eoji8ENUEDMqJlvQGi090ZaNPM6Sq7nZUfKbGiJmYkPy9MuufL//ERxtxQZE?= =?us-ascii?Q?wYTQCvxmsz+XPG3Peu/TkkMv2q4sZGlNI0lsQnCwYDlH?= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: meta.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR15MB5109.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c163f6a9-1e4d-431e-f032-08daac84346c X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2022 19:01:44.0936 (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: d70LJ/ZN246gnmDp8RV1076CMdJlpBLsFHY/FUp3LmpwwIl+9Qg1XBMuyjUckvHByOBnVY269SjohosSpG3jOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR15MB4829 X-Proofpoint-GUID: xnik_8CyEmvtJ4yFWGYT0rNpzTCj0uRn X-Proofpoint-ORIG-GUID: xnik_8CyEmvtJ4yFWGYT0rNpzTCj0uRn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-12_09,2022-10-12_01,2022-06-22_01 ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1665601314; a=rsa-sha256; cv=pass; b=AS3Yd+oeiUW3WIWGcPJiUAF22S9OHVl4zoAWiHtM72FgTysbweImHa2rSs0beGw54sm2aI YJ/r5bcCNmnwfJaf0eaGLGOnYUnJRqY0kya12WBr1bqk0DTYnT82yGj/3Ay08RAXWYPcPV FgHxwLxM5RelDWbmQidCl1dpFRJ2EN8= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=meta.com header.s=s2048-2021-q4 header.b=OUWaE8ig; spf=pass (imf27.hostedemail.com: domain of "prvs=1284ab4e42=songliubraving@meta.com" designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=1284ab4e42=songliubraving@meta.com"; dmarc=pass (policy=reject) header.from=meta.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665601314; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=g1ELcvrprxkFZskJoh7K/MQP35fAERgJDHE+QM6hj/k=; b=ofShKG4/FMiJnUIEvQK/Y4fMHDiYOSZ5SsWb19joHretD9OEEny3AbslHKVCiyEj0ldogr ESwtNnhMssXWxSva0P5MTJCr1JqQusX1jw3ksqfq3IH+zcOUsCtMNkTDWsOKFkfqiKzIa5 HINa8DDC5aC+m5SpgDu6Xa2PLp/8g3Q= X-Stat-Signature: b7q1gs5d9tbu4snkkks1nix16gcit775 X-Rspamd-Queue-Id: 1EBFE40025 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=meta.com header.s=s2048-2021-q4 header.b=OUWaE8ig; spf=pass (imf27.hostedemail.com: domain of "prvs=1284ab4e42=songliubraving@meta.com" designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=1284ab4e42=songliubraving@meta.com"; dmarc=pass (policy=reject) header.from=meta.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-Rspamd-Server: rspam06 X-HE-Tag: 1665601313-709334 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: > On Oct 12, 2022, at 11:38 AM, Edgecombe, Rick P wrote: >=20 > On Wed, 2022-10-12 at 05:37 +0000, Song Liu wrote: >>> Then you have code that operates on module text like: >>> if (is_vmalloc_or_module_addr(addr)) >>> pfn =3D vmalloc_to_pfn(addr); >>>=20 >>> It looks like it would work (on x86 at least). Should it be >>> expected >>> to? >>>=20 >>> Especially after this patch, where there is memory that isn't even >>> tracked by the original vmap_area trees, it is pretty much a >>> separate >>> allocator. So I think it might be nice to spell out which other >>> vmalloc >>> APIs work with these new functions since they are named "vmalloc". >>> Maybe just say none of them do. >>=20 >> I guess it is fair to call this a separate allocator. Maybe=20 >> vmalloc_exec is not the right name? I do think this is the best=20 >> way to build an allocator with vmap tree logic.=20 >=20 > Yea, I don't know about the name. I think someone else suggested it > specifically, right? I think Luis suggested rename module_alloc to vmalloc_exec. But I=20 guess we still need module_alloc for module data allocations.=20 >=20 > I had called mine perm_alloc() so it could also handle read-only and > other permissions. What are other permissions that we use? We can probably duplicate the free_text_are_ tree logic for other cases.=20 > If you keep vmalloc_exec() it needs some big > comments about which APIs can work with it, and an audit of the > existing code that works on module and JIT text. >=20 >>=20 >>>=20 >>>=20 >>> Separate from that, I guess you are planning to make this limited >>> to >>> certain architectures? It might be better to put logic with >>> assumptions >>> about x86 boot time page table details inside arch/x86 somewhere. >>=20 >> Yes, the architecture need some text_poke mechanism to use this.=20 >=20 > It also depends on the space between _etext and the PMD aligned _etext > to be present and not get used by anything else. For other > architectures, there might be rodata there or other things. Good point! We need to make sure this part is not used by other things. >=20 >> On BPF side, x86_64 calls this directly from arch code (jit engine),=20 >> so it is mostly covered. For modules, we need to handle this better.=20 >=20 > That old RFC has some ideas around this. I kind of like your > incremental approach though. To me it seems to be moving in the right > direction. Thanks! Song=