From patchwork Mon Oct 7 07:50:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824286 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 3452ACFB43F for ; Mon, 7 Oct 2024 07:50:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 856096B00F5; Mon, 7 Oct 2024 03:50:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8058D6B00F6; Mon, 7 Oct 2024 03:50:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CCD36B00F7; Mon, 7 Oct 2024 03:50:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4C4EE6B00F5 for ; Mon, 7 Oct 2024 03:50:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E63851214CD for ; Mon, 7 Oct 2024 07:50:54 +0000 (UTC) X-FDA: 82646034828.26.454A777 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf27.hostedemail.com (Postfix) with ESMTP id D1DE640002 for ; Mon, 7 Oct 2024 07:50:52 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=poOqPz0u; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nyQylENW; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=poOqPz0u; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nyQylENW; spf=pass (imf27.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728287319; 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:references:dkim-signature; bh=E+D2Dok2cV3K0Z2U3dJxB5/BdOvN2cE918nP3F/1OwU=; b=h8tiKDBW7Q2FcMGCsQIwBmMyphITiZnKAgBef3ZJGO1aTHxPKnVrBTcfX6kGVTiMbuLY3B rMeDHRWFzyIHBAmmzoG8ysJcCP3jFdhhdqn7ks+McVjES+TO+XloIf2olEsTdu/OpcYs2p e1g680+Fp9Nu5w40YcNXhy8R4pg8JUc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728287319; a=rsa-sha256; cv=none; b=8ingtIqKFNGc+mW3TvVM25IhZ8g7t5VB81tdOyNwNRCb7y5avpofwZvXQ9+5b65QlOO0Vt DkHXWVWz12KwoaVgeUmr+fW0uj42ApVjftWNdMvpON7/8fBOQJuBrjMOvjIvHMgSBFJNZS 2F9bypR9ygIvQCUi6pIe3CcqfEp1etU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=poOqPz0u; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nyQylENW; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=poOqPz0u; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nyQylENW; spf=pass (imf27.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3539121BB5; Mon, 7 Oct 2024 07:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728287451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=E+D2Dok2cV3K0Z2U3dJxB5/BdOvN2cE918nP3F/1OwU=; b=poOqPz0u0LO80DSPbgUL/W3ooEloBAyuHxQlJe6HfnIYEYCdddziy86T4risdDfw+bQKPq 4gKs5ohjUzcHEqWj6yV5AbViMBaemYzAO/6gsvrJ02AvqhdXX4Zkqd1JjbaWvheYgcpgAL Y0EgB4FA3kP6/PG0RGQm1mrmeVtlqgw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728287451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=E+D2Dok2cV3K0Z2U3dJxB5/BdOvN2cE918nP3F/1OwU=; b=nyQylENWb3m6KmK5mrXBImmuc36kOzmYxpTdS840zUwwrYHozykOLvRDh0fguAcccIbyjf 4+NOsj3TJ/FottAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728287451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=E+D2Dok2cV3K0Z2U3dJxB5/BdOvN2cE918nP3F/1OwU=; b=poOqPz0u0LO80DSPbgUL/W3ooEloBAyuHxQlJe6HfnIYEYCdddziy86T4risdDfw+bQKPq 4gKs5ohjUzcHEqWj6yV5AbViMBaemYzAO/6gsvrJ02AvqhdXX4Zkqd1JjbaWvheYgcpgAL Y0EgB4FA3kP6/PG0RGQm1mrmeVtlqgw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728287451; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=E+D2Dok2cV3K0Z2U3dJxB5/BdOvN2cE918nP3F/1OwU=; b=nyQylENWb3m6KmK5mrXBImmuc36kOzmYxpTdS840zUwwrYHozykOLvRDh0fguAcccIbyjf 4+NOsj3TJ/FottAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8340A13A55; Mon, 7 Oct 2024 07:50:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id /7kuHdqSA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:50 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Xu , Muchun Song , David Hildenbrand , Donet Tom , Vlastimil Babka , Michal Hocko , Lorenzo Stoakes , Oscar Salvador Subject: [PATCH v4 0/9] Unify hugetlb into arch_get_unmapped_area functions Date: Mon, 7 Oct 2024 09:50:28 +0200 Message-ID: <20241007075037.267650-1-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D1DE640002 X-Stat-Signature: f1modekrdtbzr7tbos74t3x319upg3wx X-HE-Tag: 1728287452-279520 X-HE-Meta: U2FsdGVkX1+GRLtH1gYjo8+jG+961XZKQJ0tkwOER6/l3+ZHYVhSj4y5fmPerGLrbWZT+Nc8F8/mPS3EYe+Q4/BMh6Pdw1+ctWboCA/ia2L2pU4FQBHXrS9Ceefn6ggI4E0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Kc6Ni+iIG5dteimm7Xkle5bk4EqZczAq28XuM1ewRAyfmI2+Ww6M+EDX5bfg2vj5S9hcECiJ7Is4ZO8IhqF7dGCAlj/Zw== 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: List-Subscribe: List-Unsubscribe: rfc -> v1: Fix s390 compilation errors Tested on s390 v1 -> v2: Rebased on top of mm-unstable Fix sparc64 compilation errors v2 -> v3: Rebased on top of mm-unstable Fix bug reported by Lorenzo Stoakes v3 -> v4: Rebased on top of mm-unstable Fix warning and error reported by Intel robot This is an attempt to get rid of a fair amount of duplicated code wrt. hugetlb and *get_unmapped_area* functions. HugeTLB registers a .get_unmapped_area function which gets called from __get_unmapped_area(). hugetlb_get_unmapped_area() is defined by a bunch of architectures and it also has a generic definition for those that do not define it. Short-long story is that there is a ton of duplicated code between specific hugetlb *_get_unmapped_area_* functions and mm-core functions, so we can do better by teaching arch_get_unmapped_area* functions how to deal with hugetlb mappings. Note that not a lot of things need to be taught though. hugetlb_get_unmapped_area, that gets called for hugetlb mappings, runs some sanity checks prior to calling mm_get_unmapped_area_vmflags(), so we do not need to that down the road in the respective {generic,arch}_get_unmapped_area* functions. More information can be found in the respective patches. LTP mmapstress hugetlb selftests were ran succesfully on: - arm64 - powerpc64 - s390 - x86_64 Oscar Salvador (9): mm/mmap: Teach generic_get_unmapped_area{_topdown} to handle hugetlb mappings arch/s390: Teach arch_get_unmapped_area{_topdown} to handle hugetlb mappings arch/x86: Teach arch_get_unmapped_area_vmflags to handle hugetlb mappings arch/sparc: Teach arch_get_unmapped_area{_topdown} to handle hugetlb mappings arch/powerpc: Teach book3s64 arch_get_unmapped_area{_topdown} to handle hugetlb mappings mm: Make hugetlb mappings go through mm_get_unmapped_area_vmflags mm: Drop hugetlb_get_unmapped_area{_*} functions arch/s390: Clean up hugetlb definitions mm: Consolidate common checks in hugetlb_get_unmapped_area arch/loongarch/include/asm/hugetlb.h | 5 -- arch/mips/include/asm/hugetlb.h | 4 - arch/parisc/include/asm/hugetlb.h | 15 ---- arch/parisc/mm/hugetlbpage.c | 21 ------ arch/powerpc/mm/book3s64/slice.c | 50 ++++++++----- arch/s390/include/asm/hugetlb.h | 73 ++++-------------- arch/s390/mm/hugetlbpage.c | 85 --------------------- arch/s390/mm/mmap.c | 9 ++- arch/sh/include/asm/hugetlb.h | 15 ---- arch/sparc/kernel/sys_sparc_32.c | 17 ++++- arch/sparc/kernel/sys_sparc_64.c | 37 +++++++-- arch/sparc/mm/hugetlbpage.c | 108 --------------------------- arch/x86/kernel/sys_x86_64.c | 24 ++++-- arch/x86/mm/hugetlbpage.c | 101 ------------------------- fs/hugetlbfs/inode.c | 94 +++-------------------- include/asm-generic/hugetlb.h | 15 ++-- include/linux/hugetlb.h | 22 +++--- mm/mmap.c | 4 + 18 files changed, 145 insertions(+), 554 deletions(-)