From patchwork Tue Sep 10 08:00:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13798081 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 D8AA0ECE582 for ; Tue, 10 Sep 2024 08:00:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F8248D0027; Tue, 10 Sep 2024 04:00:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BD5F8D0029; Tue, 10 Sep 2024 04:00:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74A9A8D0028; Tue, 10 Sep 2024 04:00:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4FD118D0026 for ; Tue, 10 Sep 2024 04:00:55 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 134FB160E85 for ; Tue, 10 Sep 2024 08:00:55 +0000 (UTC) X-FDA: 82548082470.22.3FB3938 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf16.hostedemail.com (Postfix) with ESMTP id B8992180025 for ; Tue, 10 Sep 2024 08:00:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=eJPFyJGc; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=74BzRS9G; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=C4YXpm7r; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="/wH8E5Ra"; spf=pass (imf16.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 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=1725955200; 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=yhO/qT0Y3vWGEa3fn0GR7ldtqThYO6oEScDupqRpLgQ=; b=ks9/WtppwFaID4hWcJfYNfkYmKiXFkptewLuO4lkahI0gXo0WMT5oSJ91u8Kp+5ecM9C0V /96sUoKOTR1eZoOf1LU2+MWbazTtBccyLQMVt36g1841RKdW7MuXIf5X1QYA8vFfur8sbq 1qjuC1AcpRFTjUm3LcZB6S2GqS41pPM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=eJPFyJGc; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=74BzRS9G; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=C4YXpm7r; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="/wH8E5Ra"; spf=pass (imf16.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725955200; a=rsa-sha256; cv=none; b=PCIaKDyyGc5J5i+w7anwxvYdyDs1T5ZXFaupdrb+wlAON0fDEGwb5WnqXv8CjvpxJfrQVZ FzFfuBHeQdNmJjhgn8t3iyUsRAmc89VbfNaIj6WFp1FxyY66/DICqpMKsaHVoZ3YZZX11K HVGxVuQSnqhAPGXPgOIxg8pu3gkFxR8= 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 983061F807; Tue, 10 Sep 2024 08:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725955249; 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=yhO/qT0Y3vWGEa3fn0GR7ldtqThYO6oEScDupqRpLgQ=; b=eJPFyJGc7T5bsLOx7C9nrdYUPc+aCgqJTr8YSFsdVEhlNIAJvRKWsMmMNeCnzybrrlttKo Ai9Y7LbsGvSNEK89VL68GLp/JN6p5btcwdslj5Dtj9iegSyQucC3KYz0DmKOWN1t5PIH8Q UsXpLZzZhusa2FS9G+zZn4IJgZJHPzE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725955249; 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=yhO/qT0Y3vWGEa3fn0GR7ldtqThYO6oEScDupqRpLgQ=; b=74BzRS9GV3ZxX2uSR4O8WJojQp9lt4qAik3zfRUzFcFSm+DsjM5YPAi2y8fB+z1nsuQm0h B085gA7RQpJFZfBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1725955248; 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=yhO/qT0Y3vWGEa3fn0GR7ldtqThYO6oEScDupqRpLgQ=; b=C4YXpm7ruSLBIiVmdwThvMhXaOUW8TeKXPmnGIZlwBLQ2Leveh2tjAOHIZnbOsAB1Kczph 9YPyiMh/fgFa/0DzOdN9Fp/Eo6786LG026TdBxJJcNjP+nFr8/vH+Ded4cxzuMOqQTcgoA 9DT80zsrMr12mr4acFeGtY2T54KL6xU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1725955248; 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=yhO/qT0Y3vWGEa3fn0GR7ldtqThYO6oEScDupqRpLgQ=; b=/wH8E5Rab0LLjfUunG1XAkVXoT0RgMvIzhTYwCnkAXzKKLh9epmiDaz0cYKl+QwyRt6/Im 4eeyt5BB2CzayNDw== 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 DB03C132CB; Tue, 10 Sep 2024 08:00:47 +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 calzMq/832Y2MQAAD6G6ig (envelope-from ); Tue, 10 Sep 2024 08:00:47 +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 , "Liam R . Howlett" , Oscar Salvador Subject: [PATCH v3 0/9] Unify hugetlb into arch_get_unmapped_area functions Date: Tue, 10 Sep 2024 10:00:21 +0200 Message-ID: <20240910080030.1272373-1-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspamd-Action: no action X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B8992180025 X-Stat-Signature: 5dqp3rit7wic5rrx1ooi7mpe849df116 X-HE-Tag: 1725955251-593926 X-HE-Meta: U2FsdGVkX19UYZI36ypPM2k3VumVkyKt0TcMTCAoyNqasuGa73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nZkzckvJxYPireT0zifnsa7P6TndJ/UBJX00KbJKikXa9UHK1CGfG9XZVUHf87J9PsHZTdzRrXvmNycmy9FMsFsO2k+ifzUGZlW4wCJPJzHoR4eVG6RB6yPsh/YBUkkL6+UFLccnIBaQvAR5e+hE57FK61a7950abe81JN2bD4XL1heBAPEDEg== 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 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 | 4 - 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(+), 553 deletions(-)