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 33EBDC54798 for ; Thu, 29 Feb 2024 12:15:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 947166B00DC; Thu, 29 Feb 2024 07:15:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CFC36B00DD; Thu, 29 Feb 2024 07:15:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 796EE6B00DE; Thu, 29 Feb 2024 07:15:56 -0500 (EST) 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 6BB2E6B00DC for ; Thu, 29 Feb 2024 07:15:56 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 18B3740F53 for ; Thu, 29 Feb 2024 12:15:56 +0000 (UTC) X-FDA: 81844737912.06.C3BA311 Received: from out162-62-58-216.mail.qq.com (out162-62-58-216.mail.qq.com [162.62.58.216]) by imf21.hostedemail.com (Postfix) with ESMTP id E40721C0026 for ; Thu, 29 Feb 2024 12:15:51 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=qq.com header.s=s201512 header.b=d5v9QSPE; spf=none (imf21.hostedemail.com: domain of cyy@cyyself.name has no SPF policy when checking 162.62.58.216) smtp.mailfrom=cyy@cyyself.name; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709208953; a=rsa-sha256; cv=none; b=N/YhW7dopFAWgqdsqVyPfESldY8r9ZszP2WL5EvC8RgY0QUfMbzq4P+AyLBjEF+WLmAIMm CJhk0wfPsjfpOpL4glHoEaK8QhtQNASsDFhR89x9uUdODbzPdauQytYkN6QyjxUmr5fTaW uzYJvC7MOCfQDNyIIL9RayR3ABu6rnA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=qq.com header.s=s201512 header.b=d5v9QSPE; spf=none (imf21.hostedemail.com: domain of cyy@cyyself.name has no SPF policy when checking 162.62.58.216) smtp.mailfrom=cyy@cyyself.name; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709208953; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FXLGu9tMm3TBy8l3UYEso98K6Li1B3GrMam+HnDFMzg=; b=XX3BP2qZjk+sUqWyWhbYIb7VudZje9Za7APSIGVB4RoKBSW+a7yx4c+Nn7LtAuQ0igQXOV ZL6Qv+TjtrRmagyBVplc/rJpC2OTiivGGzoqExJJIvbZYgov5oRK4M9OnosyPzpZlHqiVb ELqWzaibqK5oRvtuTxfC8CCtzM+uZq0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1709208634; bh=FXLGu9tMm3TBy8l3UYEso98K6Li1B3GrMam+HnDFMzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d5v9QSPEyEZTpth4ZJJYpv5M9SezOZsW1CDhrG2mqXuwbU+WbMO1rNoEObKbDcONs cQG8fvllsRuUkoY6hV80ssZq6M4IW++OpxxTS1NW0QyxXAndGpginqJ/pik6oQ3wuV JLqSJXoQ5wDeGeCgJN1NhOoZkcoHUB8XfPCKPEWQ= Received: from localhost.localdomain ([2001:da8:c800:d084:427:1102:8aff:8b6e]) by newxmesmtplogicsvrszb9-1.qq.com (NewEsmtp) with SMTP id 283B6817; Thu, 29 Feb 2024 20:10:03 +0800 X-QQ-mid: xmsmtpt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FQtp HKvpSw1lp9WcRue8QlEKNlloIuotM4WRHVz055rwDcpDbqld5tAgrjraCD+q5ufZNfK32a8/SUxO YgY/XV X-QQ-XMRINFO: OD9hHCdaPRBwq3WW+NvGbIU= From: Yangyu Chen To: cyy@cyyself.name Cc: alexghiti@rivosinc.com, andy.chiu@sifive.com, charlie@rivosinc.com, conor.dooley@microchip.com, guoren@kernel.org, jszhang@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, paul.walmsley@sifive.com Subject: Re: [PATCH v2 0/3] RISC-V: mm: do not treat hint addr on mmap as the upper bound to search Date: Thu, 29 Feb 2024 20:10:03 +0800 X-OQ-MSGID: <20240229121003.14374-1-cyy@cyyself.name> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E40721C0026 X-Stat-Signature: nzzwo8rcp3x6mximhrzjpprja6qqzcze X-Rspam-User: X-HE-Tag: 1709208951-954883 X-HE-Meta: U2FsdGVkX19T6Udgg0NXkpMVE/uXWoTYy2ZSMcLs5Y+514mfr7Yozb4iOSJYSek5nhKl33zG8f1ietacb2LI2vbvDIA2Ucb61qqtvqaUMPw6wp/BAD1HIRJqKnAyUdnES0AB9eILVF5f5VWWLZAkxs9WNtneAvyupghKGQyEATPuDTS3uNW2GtAKXddZdUg3koK7So23JP4fya4PmNDqc2W8dQxVkXjYfs2V775kMNf6l2M/LWP0pEyGwGxNj014TN/Jfqik4fidGAP4CeTT62m6qcjtnBNbNmpZaE8NdRmQradMemBzDy/OWKHQ/xiJq7jKHVRELYN8CdkuMi66UTHM8BcQqXh3DBAHF+ufvA/sdWtfo9hIXQn419QgPJaJXiQTvvAhNP2xpr++FBnepx8KT8+PB1wDoISh18/MfXvqf9JCJxVYJQ7eQLQX4GUYGLvs5i21SueiwRoSB91Ziwv8f0zST3eVj7gCCdiqySICS3RwisSZZB8NmU6JsVjGqp2Q4Zs1/c5iv99+I2RKx4Q1/Kj76UvYlX9LNonIgO1N48jCoLo3GQ0+ANS7C7jdsNqLZ2sN4oOK6hT6IM2abO4CNYzJVELCJJIqzWvjXoHdFshRZE4RKHxF68CVTaZdqpDV2k+ryClGZCBVK4MNJ9saXN61AkeQNnE5BBslzTIqahubYalRc0bB8P1BFIUC+8g+szJ0VQ5FCJISp4QP2+d1MBbdgGe9mjnHH3ds7ZE9jon0mRCnRgVFT8iWHa7sDToisGkXxEh5V6MrELyEzAq9ItBM4zBLeXvFWQpzE9BA0sm4TJez+iNXQBehjsfyorQ3ih+945Gi2df222RH1t3tFM2RHauZRkONYyNfP7znpyB8e2gbuBY0ILJ3mTc1lVfQLQg0AhYZvB76ZA+Y6dGjqDWjj7LGTuDuxKThaIqNj1nlzwq6HfWlFfxInMZ9hu/38AnUV+88kBzm21v n3kqVASj pu3q8TfEavtxsBNZP0St5hm2N89JTH6lH16UegYRFYjxSWEQB/+zXLAAqBUSeT7W1Nh/KykNiGtN8fHfmcbPJDttOrkje4JyQQcOn4UTAPS1DE16aHMw1MYn+4rPHr63vReDYo3fNZHunCcL4yOjqGDpm+mzDK0k0QIhtxVms3hSbJaXvK2vLv/8zu3RLPwgAS2keIbFIZGFpzXhb4MiyXoR/I+J+ZQMFepLzeZWXnbmGwQwczMYJjqpJSdZMjg10NihF X-Bogosity: Ham, tests=bogofilter, spamicity=0.016945, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This patch has not been reviewed for more than a month. There is another patch that did the same fix but in another way and still has not been reviewed like this. I'm here to do a comparison of some choices briefly to let the maintainer understand the issues and the solutions. I think it's time to make a decision before the next Linux LTS v6.9. As a number of sv48 chips will be released this year. Issues: Since commit add2cc6b6515 ("RISC-V: mm: Restrict address space for sv39,sv48,sv57") from patch [1], userspace software cannot create virtual address memory mapping on the hint address if the address larger than (1<<38) on sv48, sv57 capable CPU using mmap without MAP_FIXED set. This is because since that commit, the hint address is treated as the upper bound to create the mapping when the hint address is larger than (1<<38). Existing regression for userspace software since that commit: - box64 [2] Some choices are: 1. Do not change it Con: This behavior is not the same as x86, arm64, and powerpc when treating memory address space larger than 48-bit. On x86, arm64, and powerpc, if the hint address is larger than 48-bit, mmap will not limit the upper bound to use. Also, these ISAs limit the mmap to 48-bit by default. However, RISC-V currently uses sv39 by default, which is not the same as the document and commit message. 2. Use my patch which limits the upper bound of mmap to 47-bit by default, if the hint address is larger than (1<<47), then no limit. Pros: Let the behavior of mmap align with x86, arm64, powerpc Cons: A new regression for software that assumes mmap will not return an address larger than the hint address if the hint address is larger than (1<<38) as it has been documented on RISC-V since v6.6. However, there is no change in the widespread sv39 systems we use now. 3. Use Charlie's patch [3] which adjusts the upper bound to hint address + size. Pros: Still has upper-bound limit using hint address but allows userspace to create mapping on the hint address without MAP_FIXED set. Cons: That patch will introduce a new regression even for the sv39 system when creating mmap with the same hint address more than one time if the hint address is less than round-gap. 4. Some new ideas currently are not on the mailing list Hope this issue can be fixed before the Linux v6.9 release. Thanks, Yangyu Chen [1] https://lore.kernel.org/linux-riscv/20230809232218.849726-2-charlie@rivosinc.com/ [2] https://github.com/ptitSeb/box64/commit/5b700cb6e6f397d2074c49659f7f9915f4a33c5f [3] https://lore.kernel.org/linux-riscv/20240130-use_mmap_hint_address-v3-0-8a655cfa8bcb@rivosinc.com/