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 729B0C6FD1D for ; Wed, 15 Mar 2023 11:20:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 131026B007B; Wed, 15 Mar 2023 07:20:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BB826B007D; Wed, 15 Mar 2023 07:20:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E79F66B007E; Wed, 15 Mar 2023 07:20:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D46DF6B007B for ; Wed, 15 Mar 2023 07:20:22 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A730D1C5028 for ; Wed, 15 Mar 2023 11:20:22 +0000 (UTC) X-FDA: 80570889084.30.FF452C2 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf30.hostedemail.com (Postfix) with ESMTP id 3D6BE80014 for ; Wed, 15 Mar 2023 11:20:19 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=JODU+NKT; spf=pass (imf30.hostedemail.com: domain of quic_zhenhuah@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_zhenhuah@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678879219; 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=nAmy6rM43Ucr5kkv/7b/BMijHMw5P7vDYkyBBuCOLVU=; b=WsilqGTRuDh27fJURSMB8GXCTZCCiaeU/49WDrAC2YF2wAFs1jfUmowpS3ZdrzjODob1kf ayIUtFWzmMl5NKqqsnfOhD1j/83DbHQNsaHx03oOZkLrMc4MuXoeWpAXAPSkEZVnkf5deS hMngnGWVlMhYn08PYX/hcVCQVGnJ/aI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=JODU+NKT; spf=pass (imf30.hostedemail.com: domain of quic_zhenhuah@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_zhenhuah@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678879219; a=rsa-sha256; cv=none; b=SE3ZfJB9GcQnCkRoauXTnDxl6IF75tW+KOCJWJqjykYqXnPBs05H5rHjBxar8Q2V/+Cvoc oYKdJ3okbANKeShH+J9+G/TQWQykVfsQfcLQjoJQct7CCgVijJnftPwKkf4a2Er/hssamY ZVBqRxTLDmR456qPl6PVt090+LriWgA= Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FALQu2027036; Wed, 15 Mar 2023 11:20:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=nAmy6rM43Ucr5kkv/7b/BMijHMw5P7vDYkyBBuCOLVU=; b=JODU+NKT00lal+FQWJR/Rrx7xjtd5nLqFt82NDVvrK88IsLo+oDLg1Hx5GHNS26C93Q2 Gpp2cB6jnEafWqZrKx21ACxRoonUnCWYkJr6YCDbocMJ0kkpcLVEz6dfYDn2eYXHJPHA eTrS3qR568iekK0C032+N/aIseDd1ms3wN5Jr9LGkz+DRQDv8N0jYApl7fKxxsIgiKAK d1nrQ1CRG4cGegW1ufNLZlBknKf9w0gx1IubLiIu2BVPr3QNHbDw041A325pqV794qMK CaFTwck5Lz7RlzyjJZw7Iul24oA+BWNijwRIFJDGaULpR4TOWqtGccMuxZsc4IxN0uLM Pw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pb2c21axg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 11:20:04 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FBK43U005147 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 11:20:04 GMT Received: from [10.239.132.245] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 15 Mar 2023 04:20:00 -0700 Message-ID: <10f77045-e3b6-3a12-ed6f-0279c155c462@quicinc.com> Date: Wed, 15 Mar 2023 19:19:57 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v8] mm,kfence: decouple kfence from page granularity mapping judgement Content-Language: en-US To: Marco Elver CC: Pavan Kondeti , , , , , , , , , , , , , , , , References: <1678777502-6933-1-git-send-email-quic_zhenhuah@quicinc.com> <20230314083645.GA556474@hu-pkondeti-hyd.qualcomm.com> <20230314111422.GB556474@hu-pkondeti-hyd.qualcomm.com> <3253f502-aa2e-f8c9-b5bd-8eb20e5f6c5e@quicinc.com> From: Zhenhua Huang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 59O3P8cWaavlzXeXE_0lMYTW0IIQl3wB X-Proofpoint-ORIG-GUID: 59O3P8cWaavlzXeXE_0lMYTW0IIQl3wB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_04,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 clxscore=1015 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150097 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3D6BE80014 X-Rspam-User: X-Stat-Signature: xa8bph9yaj58eutjciote5o4qf7yuf85 X-HE-Tag: 1678879219-444166 X-HE-Meta: U2FsdGVkX1+E5P2Br+VBwRO+ozZGkPhDRtk2R6LVPE1WWhCZs6+OMdcwr/i3rB1Lg3yxn4vMFBkIuNr+VKmo4vRft8WcPj7Ornq35StjNxEqVEmQ+ckC+W9Hf/ERLFrwJDssQjJf1gic8wIvxGehrMWLeL6UB/ydHQ8Za64nbJA57S9lHqWV83kaHOWBertusvUDZanGnIxC37vSMkAbxmncPuMXa/kteEwR3n2hjvQWf4vGB0AYBvhAHltL+2FuEqO7Fg7KKK7KVv3x4YUEGWsabW/WIpHYn+WzlmymEeKrDAUbV1N7UV5/HoTolP3PFeCCINkaC92egSLto1sJLTatdsWkOjrhUQQcEH0D/B7miL1IpEeSY6Br+DOQN6QJTuw4Ypj3F1TJ4OuZnkFFGbhVGbuuq0zZLrMDyf1UNd3Iqv6w5NLHc/reFk1VqRANTgVixy1mt2SMz2vRtnOlba4R2TV72+4PrB3tfv3dLjjZKJ69zXfAFbzEyO3IVYy9SE4X52EFUynTV3Ct1HBT3RMWXIa5+dgBrIni49JKqCQDkun0lcEW2AsZjEc1/jjaFOFfICfMfOspHY6xx2dr+Uo0fHJ1v+ZSJ/AfAxo7uTQVzZw5if6XR0uL8dqzM45Pe1IaaOSElTGRVHkletboSfrXnc67pITiTIe7mRla6e/8T2GJJMg0tj1c6hbbr1EiBqt0LWX/4Qmkt1RrWt+LBCJrUA/10fl0Bx3eG/8JudpVbfLLZli28xcawvVhUNGvJl2vZpDrL1rF/tPfnmyJgmV/GppGE5Leohrz/1/MpW6QT0aOhJe0gXhfQVv2wyK/x53ZLi44NstMWMdnxxTLnh0gJBEnKD8662ZT7TAHD9by3MGGTwdiDuqVYQ9PqG0IAxJMgptCMp/b+ppsfu3uyLP00Kt4wkxO1+36J4BRJfGGmu8E3jc/N1W9eFfqIImU0yRrRYebde4ybl82IRm awYXQFLX On7XlwlaBu4NAV+xiUcx0Rnx3A9eDd/l9P18Sv6tGN4VxxDYGktmrdVCu71V04nv46bCS92nwVVKuWR0mvuket/ip1/J+3q20/galcTcMF02Jvhl6iBr6ERJ3IXmtR8KPLY6zHvhU+dU3CD5YOYNsNUZ6HjEibW42GbndVo5w9swdsqRKOZ0/nMh9emn0sRT0BhkkCB41s/5BzZvbGCuQ6CK2zMT8XL6TSXhX 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 2023/3/15 16:52, Marco Elver wrote: > On Wed, Mar 15, 2023 at 02:51PM +0800, Zhenhua Huang wrote: > [...] >>> Is it possible to free this early allocated memory later in >>> mm_init()->kfence_alloc_pool()? if that is not possible, can we think of >>> adding early param for kfence? >> >> If we freed that buffer, there may be no chance to get that page granularity >> mapped buffer again.. as all these allocation/free are through normal buddy >> allocator. >> >> At this stage, seems only additional early param can work.. Marco previously >> wanted to reuse sample_interval but seems not doable now. >> >> Hi Marco, >> >> Sorry, Can we thought of the solution again? like >> ARM64: >> 1. intercepts early boot arg and gives early alloc memory to KFENCE >> 2. KFENCE to disable dynamic switch >> 3. disable page gran and save memory overhead >> The purpose is in the case of w/o boot arg, it's just same as now.. arch >> specific kfence buffer will not allocate. And w/ boot arg, we can get >> expected saving. > > You can get kfence.sample_interval with early_param(). mm/kfence/core.c > should be left as is with a module param, so it can be set at runtime in > /sys/modules/kfence/parameters/. > > However you can add this to the #ifdef CONFIG_KFENCE in arm64 code > you're adding: > > static bool kfence_early_init __initdata = !!CONFIG_KFENCE_SAMPLE_INTERVAL; > static int __init parse_kfence_early_init(char *p) { > int val; > > if (get_option(&p, &val)) > kfence_early_init = !!val; > return 0; > } > early_param("kfence.sample_interval", parse_kfence_early_init); > > Nothing is preventing us from parsing kfence.sample_interval twice > during boot. At this stage you don't need the actual sample_interval, > only if kfence.sample_interval was provided on the cmdline and is not 0. > > That will avoid adding another new param. I'm fine with above solution, Thanks Marco. Let me make the patch and share further. Thanks, Zhenhua > > Thanks, > -- Marco