From patchwork Thu Jul 18 10:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13736385 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 33127C3DA60 for ; Thu, 18 Jul 2024 10:59:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A15806B0083; Thu, 18 Jul 2024 06:59:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C56C6B0088; Thu, 18 Jul 2024 06:59:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88D116B0089; Thu, 18 Jul 2024 06:59:17 -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 653D26B0083 for ; Thu, 18 Jul 2024 06:59:17 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DF70E1A1ADB for ; Thu, 18 Jul 2024 10:59:16 +0000 (UTC) X-FDA: 82352576712.15.1911483 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf06.hostedemail.com (Postfix) with ESMTP id A2A8B180012 for ; Thu, 18 Jul 2024 10:59:14 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jP04u4Ti; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+Pl4KKTX; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=b3oSIphJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0UiQITRe; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf06.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721300321; a=rsa-sha256; cv=none; b=5o+YiMN23W0XMZsHUhCupykttUxuHlF9U1wnXjDdfLehMwkPJ0zZkRA+ozFrvQ+SHExuwt bNIFSxDHN69IDgXiAi0Dz5+ocb6yx8XlO4PHYkDQUmJYRhI/ezCez1nADXbT44SSgwDeiO M091Lb7VIkwBFLO5l2cGNSa129LuXzk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jP04u4Ti; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+Pl4KKTX; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=b3oSIphJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0UiQITRe; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf06.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721300321; 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=ZFAOU3HyKG9tRnPsNhPL4DSqpPq3LSyftAT+pe/MGVc=; b=kPm0Sy0Lgc8d1qc+LUeLtzdJUgS+chhPbUa8yNNTPrVznWKv1BayNy0qbSdfQVqeIX2Lyk hLQTnmOnfgY6sJuoIdTMEuyU+ve+I3tdiRdmWcDOp1CCcoXW14m6rZDC61kS9qOJqysTvH dYdqpjz1wKXNWp0MPz/z6tfn47UAZzU= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 09B201FBB6; Thu, 18 Jul 2024 10:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721300353; 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=ZFAOU3HyKG9tRnPsNhPL4DSqpPq3LSyftAT+pe/MGVc=; b=jP04u4TiFtdKUVsw6+9h8RaPMeXwEoXBKSJnSVFW9sTMNqZpJmB9fyZ+fEKvT25o+der97 H/XJyqu0ITsQOMtsgF9fp/bSaTyDYv84pLa6tSpLHnJ/aStbYYfBaBJF6NTbVAf5l/hGRQ K8iQtRSGON/uO34Q5eQM3LEnqn+fNdg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721300353; 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=ZFAOU3HyKG9tRnPsNhPL4DSqpPq3LSyftAT+pe/MGVc=; b=+Pl4KKTXhjQVfMnKnTxftQjY0L0MOKhjrW01aYcbEbs43kTz6+Z0pUO/f4QXBFl7aTIxXi frydlOmrb6BpKvCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721300352; 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=ZFAOU3HyKG9tRnPsNhPL4DSqpPq3LSyftAT+pe/MGVc=; b=b3oSIphJjh+WSEs76GyYowWwp39g3y4SEXwzhbWSQRdL5B8DPCt91cP3JJGciTykcAZamj fGLFxucGm9SKpL2+a7aVZx7/NXgPB0v5QOAR+J5b4nzrKRQDjnPVBEM0kwQ/Ya0FdqJKEP /gZQmXocc+Vc/cetvw3gEdO8Iflj8to= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721300352; 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=ZFAOU3HyKG9tRnPsNhPL4DSqpPq3LSyftAT+pe/MGVc=; b=0UiQITRe7i8FD6UiEBclgT1AvrbjB8BWsjYhd5Et8mDY6kf7OLg7mrwzYmPp0UnS6iXud3 FB6Iwhr+/Aq5VyDA== 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 F26F0136F7; Thu, 18 Jul 2024 10:59:10 +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 PD7ZNX71mGbnVAAAD6G6ig (envelope-from ); Thu, 18 Jul 2024 10:59:10 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Xu , Muchun Song , Michal Hocko , Donet Tom , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Oscar Salvador Subject: [PATCH 0/9] Unify hugetlb into arch_get_unmapped_area functions Date: Thu, 18 Jul 2024 12:58:54 +0200 Message-ID: <20240718105903.19617-1-osalvador@suse.de> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Rspamd-Action: no action X-Spamd-Bar: / X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A2A8B180012 X-Stat-Signature: wx54wgx11e5mjq9quqx73dp7nd796ud9 X-Rspam-User: X-HE-Tag: 1721300354-3833 X-HE-Meta: U2FsdGVkX1+ujSU3uTv3RAsfRmSOWfvmZR0uHp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VxwkO0QKbRNiKn54LfX890jhjqq9Yg8oPqHVeaHwoeUJqZN5vHjj9HoABv35+F6NKAJlASPyeFqdQ/vIRCF/hWEyqvQE2nP+3ZkaXu6mkrQIWnf1wDhLih/6/7IYsd9MXE6UANMFdTTRrbzpGaF4jg5Y3pA== 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: Hi all, this is a first 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_mmap_check_and_align(), that gets called for hugetlb mappings prior to call mm_get_unmapped_area_vmflags(), runs some sanity checks and aligns the addr to huge_page_size(), 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 and hugemmap testcases 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_mmap_check_and_align arch/loongarch/include/asm/hugetlb.h | 4 - arch/mips/include/asm/hugetlb.h | 4 - arch/parisc/include/asm/hugetlb.h | 15 ---- arch/parisc/mm/hugetlbpage.c | 23 ------ arch/powerpc/mm/book3s64/slice.c | 49 +++++++----- arch/s390/include/asm/hugetlb.h | 73 ++++-------------- arch/s390/mm/hugetlbpage.c | 84 --------------------- arch/s390/mm/mmap.c | 9 ++- arch/sh/include/asm/hugetlb.h | 15 ---- arch/sparc/kernel/sys_sparc_32.c | 16 +++- arch/sparc/kernel/sys_sparc_64.c | 36 +++++++-- arch/sparc/mm/hugetlbpage.c | 108 --------------------------- arch/x86/kernel/sys_x86_64.c | 24 ++++-- arch/x86/mm/hugetlbpage.c | 100 ------------------------- fs/hugetlbfs/inode.c | 92 ++--------------------- include/asm-generic/hugetlb.h | 15 ++-- include/linux/hugetlb.h | 21 +++--- mm/mmap.c | 19 ++++- 18 files changed, 153 insertions(+), 554 deletions(-)