From patchwork Mon Oct 7 07:50:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824288 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 B5E6CCFB43F for ; Mon, 7 Oct 2024 07:50:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB206B00F7; Mon, 7 Oct 2024 03:50:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C2536B00FC; Mon, 7 Oct 2024 03:50:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAD566B00FB; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A687F6B00F7 for ; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 62E2D1C6E51 for ; Mon, 7 Oct 2024 07:50:56 +0000 (UTC) X-FDA: 82646034912.20.0B09D4E Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf05.hostedemail.com (Postfix) with ESMTP id 43AED100005 for ; Mon, 7 Oct 2024 07:50:53 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="ADp55/pX"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1lcsC+83; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="ADp55/pX"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1lcsC+83; spf=pass (imf05.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=1728287276; 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=nToqOO7GlBoRNGFY8sGJEqoQNYfVFvYYnrXC4X6coa4=; b=tS8ojYk/QH45dC0tKET7RrvZrSAZHMlt0t903/jZ4kS6BIFjr37OePtdtH3FXsE5xFcxOF CRQPGajK2LTDIbEQ5iPAuO0ZncOoW6r6/ozNKtLXQu/S/srNzGIsKO8bw6ayjvYv9oa6kM 34mdwH0moNKEFx+A3bQfYTtsUWJwbxg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="ADp55/pX"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1lcsC+83; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="ADp55/pX"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1lcsC+83; spf=pass (imf05.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=1728287276; a=rsa-sha256; cv=none; b=CAEI3/XbkUAzAEL0lERL5Ye79LAbWPl2Ufi2zTOgrtV22NhqQdgNgR4lOHHJaxzWAUSrQv EYt81wlVoCHl+GJD4WlRlve25JGu8+AA8stf1YUYBx80u/FNBnoW1cgBZniAc6Q31iVOD3 hVl4RvLC9jxm4IBpJJTHVXecy7EUz6Q= 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-out2.suse.de (Postfix) with ESMTPS id E86AA1F84F; 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: in-reply-to:in-reply-to:references:references; bh=nToqOO7GlBoRNGFY8sGJEqoQNYfVFvYYnrXC4X6coa4=; b=ADp55/pX5WI3Mg9p7PK4RW8GW+Rn9bxI4wgI+2QNBq6Fe+4lbWESvGl+Utllq62MrtNWPk LB4wW1OQQDyXt1J0DpQ0hE9L5/KW2dCukUm8O4glSBuKyPypicn+56LITTQjvd1veOmfLa fsOiF7q3ZmEisIn4G3Vi8TEQyc/DUk0= 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: in-reply-to:in-reply-to:references:references; bh=nToqOO7GlBoRNGFY8sGJEqoQNYfVFvYYnrXC4X6coa4=; b=1lcsC+839ZcPy/lvLPaLQ2i4gypqWEjq3jXCggK/8NOMN8nPKQ6m/eM6boA6rBSXNvnygJ GhKSYRbkGEIf8UBw== 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: in-reply-to:in-reply-to:references:references; bh=nToqOO7GlBoRNGFY8sGJEqoQNYfVFvYYnrXC4X6coa4=; b=ADp55/pX5WI3Mg9p7PK4RW8GW+Rn9bxI4wgI+2QNBq6Fe+4lbWESvGl+Utllq62MrtNWPk LB4wW1OQQDyXt1J0DpQ0hE9L5/KW2dCukUm8O4glSBuKyPypicn+56LITTQjvd1veOmfLa fsOiF7q3ZmEisIn4G3Vi8TEQyc/DUk0= 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: in-reply-to:in-reply-to:references:references; bh=nToqOO7GlBoRNGFY8sGJEqoQNYfVFvYYnrXC4X6coa4=; b=1lcsC+839ZcPy/lvLPaLQ2i4gypqWEjq3jXCggK/8NOMN8nPKQ6m/eM6boA6rBSXNvnygJ GhKSYRbkGEIf8UBw== 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 48676132BD; Mon, 7 Oct 2024 07:50:51 +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 MH/ODtuSA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:51 +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 1/9] mm/mmap: Teach generic_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Mon, 7 Oct 2024 09:50:29 +0200 Message-ID: <20241007075037.267650-2-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 43AED100005 X-Stat-Signature: p3xemxpxqh6bqscyz5hzde6d3fzdhwef X-Rspam-User: X-HE-Tag: 1728287453-381871 X-HE-Meta: U2FsdGVkX19E1icOF3SE5zEztOcYG7PBsP9fZ1j2rRtOKXWD07Rt9M7a6dGLw01DliC0ItLPI1BOIqMY8r/4UzmvOOkOOLMiAmRRf65DakjL5sywW1vZnKIPet0wWJzw2mHk5oe6KSQyYILmmNSnwxI1sm7CuDYagGfDQcXKicf+HRlTSSlRpYfRt3QDgc1Ka7sRRK3K9BcN0xf0/CwMSzzYiw/JUsu7aGOJqXPYYdpVGVBVQN+TRNuQe5v763BS+onnWxgF6cUEXR5kf6MnhKvLbAMJOJsoREBFXfxv8PSBHyYK6ExAF7iHZo30UauYjp8ua4WyiWi1wDRZTOmpMClcO+TZ+3ihdvH+td7gFNIV93V9USQ9qKMyMOUp63Hc0PLs+tVI2XBZY8QTNpV24gvD92EjYwIvRl20dJmauXQFUt5Omo49J4hft7FFELd/2drRRzsVFqAeeCJkaCRJOWZnwFn3cTKz1Z79EGBXlzBNLvLSGpGc0A4D8otI22XWM1nSqkdy/x9k8Flvmy12yASFDQhlCshYn7OK6bR0LW+P0/T7U34+px49NIfi5CBD6po/po49zHifVMrFqjab5uhIeHz12SNx71W27OFahKiw/PYFBimvcomvMaGLjXPs/g9JtkQNN6GvQanhUyaR246t08VbXhHLftnSOjZSQc0WYzpiYEJS39o/7e8Be4Tda0PHe5BoF+Ljur5n2QXShIETgR44Oc5FInhVkLyyTYt1LKT8muaXl4U2JmidL46i0qShRgJuU9b0vSt0xy+zFn9GbPsDpfAaAZwxr7qdSOWGj2AuLx3ijrDTnnVpxif0Ziort9imZpekXjx3Gi54gerBv8TfmpbuG4KFk7UFYk2BNl+5eHhGeppDW5WdlH4+6iJTPXQSIncMLTFTKN4GFxD9ywnHcLEy0cWkcpi4Co4GXXWGIDD56Wm84qaw7FVe9BKEatoAcdJi99kuJLG 7QbI6ZV8 UYgkiLqLMbXTJsAAmAgtOvm7JLy2/lZqLK9+VmBB87NzBQJP/nv4g+Iz9uiOMXRDmlWCwO9sejNY8ibkTskbTdWFU0g/EfIcZJr2WVMz0oDAu77cc3He4huD3UeqF5BUdBiUHjpSmSXDGyFa29DkmGquSzbcHW+O5T+mejEXm5Ri//KCKvkxRTtD9O8fA7OcHrfSo/UtbEjlZ3CL+ZJJ76s4JwNiVL7NDnu5cyE6HWkWJHQnOFZI6o3et5o8vjSW+efOpjsJzEwKZp3oJwuJjSBErS7woOMugfMX1P0Bb/+Ma5t+gB1T9f+HuCw== 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: We want to stop special casing hugetlb mappings and make them go through generic channels, so teach generic_get_unmapped_area{_topdown} to handle those. The main difference is that we set info.align_mask for huge mappings. Signed-off-by: Oscar Salvador --- include/linux/hugetlb.h | 10 ++++++++++ mm/mmap.c | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index e4697539b665..368d552e4860 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -1035,9 +1035,19 @@ void hugetlb_unregister_node(struct node *node); */ bool is_raw_hwpoison_page_in_hugepage(struct page *page); +static inline unsigned long huge_page_mask_align(struct file *file) +{ + return PAGE_MASK & ~huge_page_mask(hstate_file(file)); +} + #else /* CONFIG_HUGETLB_PAGE */ struct hstate {}; +static inline unsigned long huge_page_mask_align(struct file *file) +{ + return 0; +} + static inline struct hugepage_subpool *hugetlb_folio_subpool(struct folio *folio) { return NULL; diff --git a/mm/mmap.c b/mm/mmap.c index 9c0fb43064b5..57fd5ab2abe7 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -776,6 +776,8 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr, info.low_limit = mm->mmap_base; info.high_limit = mmap_end; info.start_gap = stack_guard_placement(vm_flags); + if (filp && is_file_hugepages(filp)) + info.align_mask = huge_page_mask_align(filp); return vm_unmapped_area(&info); } @@ -826,6 +828,8 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, info.low_limit = PAGE_SIZE; info.high_limit = arch_get_mmap_base(addr, mm->mmap_base); info.start_gap = stack_guard_placement(vm_flags); + if (filp && is_file_hugepages(filp)) + info.align_mask = huge_page_mask_align(filp); addr = vm_unmapped_area(&info); /* From patchwork Mon Oct 7 07:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824287 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 90D48CFB441 for ; Mon, 7 Oct 2024 07:50:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBF516B00F6; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E49956B00F7; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8A5F6B00FA; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 93A546B00F6 for ; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2A30641289 for ; Mon, 7 Oct 2024 07:50:56 +0000 (UTC) X-FDA: 82646034912.29.3342F6D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf03.hostedemail.com (Postfix) with ESMTP id 11A8820005 for ; Mon, 7 Oct 2024 07:50:53 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728287345; a=rsa-sha256; cv=none; b=gyquhtHnoisbVk+jX+nSvsxcoTycDmwCPYvkV/XDE5sB/9HK8xqIF+rdlREa4kO+HSPQlx ufeLsZotVg4E2GIq6DQAyvMIzw1/1e4nrfidnIitpJXhOrOAJAcGMFMqHyEq6t6rYpmXTH 1Pqxd/uUACGmfKTQqVEleK3BlwWlKXg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 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=1728287345; 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; bh=hWJGxSt8TXIQHuQog2Pqb6brVhcVjyPAR9HLfk56Q/4=; b=ZZqEV9LzfKxzqUdezBGtoOGXBDB3Ayk5E3dEtSj10f4kSicOf3sAGTOjonthzHNT9kNh8m RQJrYBsPXQS4mWZFQXPD+oyqyny/V0hDgtViP+bVRrumlUuWGSRtoJ3AsNB5OvppMhZIEl kilTcG64k0+ZnY8sBNMLp5dbz7GdQVs= 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-out1.suse.de (Postfix) with ESMTPS id A5FA721BF8; Mon, 7 Oct 2024 07:50:52 +0000 (UTC) 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 065B113A55; Mon, 7 Oct 2024 07:50:51 +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 CN9COtuSA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:51 +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 2/9] arch/s390: Teach arch_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Mon, 7 Oct 2024 09:50:30 +0200 Message-ID: <20241007075037.267650-3-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 11A8820005 X-Stat-Signature: 981mk46qx85k7ek5p4kdu9ixtonpffkq X-Rspam-User: X-HE-Tag: 1728287453-57496 X-HE-Meta: U2FsdGVkX1/Ya50NuhmGvWlVHfSG5ofPmhR0EW2yTpqOLwYSVm/miQjqJx7cSlYvdowdUsqZRJ+f1Xokmz/M2ZFdIiDccWjQeVShrdak/W+ufZr7Y/SXIKLQOTSSqHwfjvX7suM0PgvDJ1yLDdDzkQj1OOY0JtU6NLojJfDpJrierSd71n5W6sq/ErhrygwVaAwX4sfBl5Jfg7+sU5DgJKNj3VyDlXsXFbXTMDfGnaE2y31neNmU88o4MyyAv98w409tT9odRTxeXiHh3LNSgxrePthcZs7xpsz1Lcb2+VvV7DszxDF5IM5AaI7DqNEpBj06KrjuXXNbFSEuBgd2ddySM8kWMQL9lsAmiHT+t7XDzosNxUG+0DhziORL6GLZLMEkKyHoeEcM+YgGg8p73kb8HsOPKqaYU0+6OSrF+5sDKqYo2wR3QWYSs7Ft6kENK8UrcpJSfTnHRF/U8ubXFlimCz+Xl/QarecgTBOCQcCiFqcRp8Q6DMMpCw2hw5qieEXNf+3ZyX7+tEGwdvkxIwqu/+NFihDnsi1bFrYr2AL4Rt4ajP3QQKbEl1PMdGul5CZDQEWrjCPR7ZM/clOVz5OZzwdjgXwxTwY8qGBI89K1aLlDGkiDx2p0vG02eUNoR6kS2VyIFCAFOLkdN8p/8voCSfX3hYFwFNXaPlrJSCZdp4RkaCAl4Cwi7SDtBBLNk/s6lU/O0mzTRWXSSQofnIJc0smmlNlGWcUGq/T3e7gYIEB2JjGDQmYhH5y6Ifvwo9xrY6rFzHqarkBM7tBfAVqkWgZn5bMElt4wE2+zn7fzpH+D6aUIbguDz7tueWL9G62Qf16o5rMzgOoZYg7GfFBsR77TQ/ug9DCEYcMBtcRgty7Vcy8IymTHAQTJ2oaDcgGkAIvhuIBxsszX9mpDbMEc45n1Wopu6jikeHZcFd1bzVCi15QzO9G+wxN2SiLxYY8/Ac86fwL/aIpzhWY cgDFaMIO 8RkwypU8QVDfXuSxou5/RY8KGCae/Q7IklMUIHS8yvFSNry+F8YtX8cjWBUCeba5pd9UPDOrbDUVGQfP0kf17ID1SDUEi0j7LgKxjDI5QeGMFMhyFIirgjZ0UX1B1K06txw1owjlAXaLDPv0nB3xQwwel8VAM5qidybDpxelIm6fmLvg= 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: We want to stop special casing hugetlb mappings and make them go through generic channels, so teach arch_get_unmapped_area{_topdown} to handle those. s390 specific hugetlb function does not set info.align_offset, so do the same here for compatibility. Signed-off-by: Oscar Salvador --- arch/s390/mm/mmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 96efa061ce01..33f3504be90b 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -17,6 +17,7 @@ #include #include #include +#include #include static unsigned long stack_maxrandom_size(void) @@ -73,6 +74,8 @@ static inline unsigned long mmap_base(unsigned long rnd, static int get_align_mask(struct file *filp, unsigned long flags) { + if (filp && is_file_hugepages(filp)) + return huge_page_mask_align(filp); if (!(current->flags & PF_RANDOMIZE)) return 0; if (filp || (flags & MAP_SHARED)) @@ -106,7 +109,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; info.align_mask = get_align_mask(filp, flags); - info.align_offset = pgoff << PAGE_SHIFT; + if (!(filp && is_file_hugepages(filp))) + info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); if (offset_in_page(addr)) return addr; @@ -144,7 +148,8 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad info.low_limit = PAGE_SIZE; info.high_limit = mm->mmap_base; info.align_mask = get_align_mask(filp, flags); - info.align_offset = pgoff << PAGE_SHIFT; + if (!(filp && is_file_hugepages(filp))) + info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); /* From patchwork Mon Oct 7 07:50:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824289 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 2B462CFB43F for ; Mon, 7 Oct 2024 07:51:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76BA96B00F9; Mon, 7 Oct 2024 03:50:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D78F6B00FA; Mon, 7 Oct 2024 03:50:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AD386B00FB; Mon, 7 Oct 2024 03:50:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E6EAE6B00F9 for ; Mon, 7 Oct 2024 03:50:56 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B3DE6A8DD8 for ; Mon, 7 Oct 2024 07:50:56 +0000 (UTC) X-FDA: 82646034912.01.C0D699E Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf11.hostedemail.com (Postfix) with ESMTP id 9D47440011 for ; Mon, 7 Oct 2024 07:50:54 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf11.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728287429; a=rsa-sha256; cv=none; b=RH4wMkjEcYvJJxBWL3nVZSiQ7Td/VMFNmetaZgqLnvMYFLwHkn+yxP8j04/Zr69FJ4WpTN PCKj3Uwldzo0tRjt6UyLoSk4+0veNwDqKX6ZYEJmjZQ71rUslZ7q8wtceV8e1lzhSlHIt+ +wHsTpIjZuWMJZofiy7E94TXx+j6FDA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf11.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 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=1728287429; 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; bh=4CVBfBerTQRyf1IgzEWS511wYXAZxzYRFHGOxP2aS3o=; b=F+jKQHjCdfOS9S+LFPW43+0hccCNaqN6rC7uRBDdsXILEyQktH+BPiiEFzehH39bL+ymrw iO7ioZdkpx0wx0fXTtjyYG0E6bRm6Kv/QULoVpFbc9OB1J49IqFP6Wp19nJv034owip+4w 7hL/+FIuok0zqHqxgxkda4husxvYgDM= 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-out1.suse.de (Postfix) with ESMTPS id 65D3B21C4D; Mon, 7 Oct 2024 07:50:53 +0000 (UTC) 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 BACF4132BD; Mon, 7 Oct 2024 07:50:52 +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 sP+YKtySA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:52 +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 3/9] arch/x86: Teach arch_get_unmapped_area_vmflags to handle hugetlb mappings Date: Mon, 7 Oct 2024 09:50:31 +0200 Message-ID: <20241007075037.267650-4-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspam-User: X-Stat-Signature: zng4nmfs7sbo9z16k4zugkiugwu8z9u6 X-Rspamd-Queue-Id: 9D47440011 X-Rspamd-Server: rspam02 X-HE-Tag: 1728287454-251267 X-HE-Meta: U2FsdGVkX1/cri2StJiWAJ7/54ZTb1jDw4lk8RCPm0PG9Gc6DSPrp3zRyCgjSHhieQ9CPa3AYGlxuHyq+jMEdOueuCO2EHuOagozwJTMZDamSGhlaiR60Xv+UyiDrmGecLAkILiIw6TFjXQQS8WCLql2im9YnIz80SEgyjZTcNm+qK8XsFCgmzU1GMpi8z7SxBW6W4Bfyo498YUDfMpkrmJ6WWZAplTkLNw45tsXmIz+sgyxLcrbeboIMzhEKWmll3S8n8htLB97EyGckaXyWsDYk3CR6wqDO9oG+hWv7A4iRjDvXcf2yC0IIzNGXh29ARvEzkeLeuZ3XjByBWKCsA+5uvWlKMvkB/fm1FCLeYjBZ0u/AVKfz8iixo1oqISSkx81ZcwjPGt67QcJHNOZgogwSGksoUC/+/CaS2MKXZqXXnT5FCvm7rEW9D3qsvK1Twj1wUwMHScp0tARVAAziK0f7nb9Egp9rw1Pg2JiHLPEdxNddKoOVUxdWmzQPL3nBuvNWsnDl0kOlCgpB1yMOHK93SH5vHkIqdt8WZFLkPycp/yATEC2UOzC69lQltu62I2jSTmiLTgVSK/TUC5YcO6fyDn1izUp/Y7P1+zA9WTTVVEx+1UMj8peUyEiRTM63RLQlRJiA3RxwSu1+MeXzNwOEIERO4tHgce1b1LkoJxK8DAsP3vh7sIpqOJXkzFrDmZ3mXN0PAvHAyhRezKB21KHb1zDeKXB9gW1aPda7xh21m2IikPNiYECKjKmAukZCKFyHMeRv1fSZ0jteDsWPdnEQ3M0sWLRGIkTFhtGd6Q1dEAMJ8XGjnhqA2aW1SMUXrXinFHQg8qtap7Oh6ENJOP28pF159X+8uxKIn3KQqbY1wVsrxNc/DQu7lG0DAvzlr9Bz54qQsU1hC1WBJfWiw/vxZ4E12KbKnuK2/Mu/gt0KqlvNXgQdGSzlgIoVlV8zMg1iMOxvHESYRVZstI pbv1xyNc AtS89qsOD7DEU6O3dIwlEmHOmLyYvKXe1XoTbvr9tlaaS/tN308ypj2PwnEaiAK3EosDN1SN2k0VlRY9wcXoakMwhuY6gUnNquxkcLLM/UlCucFzLE6pL3dGUZoS04xvpxs8HDG8HNKsEr8vCP7xF4U/3vWNACn3bnEK3QzVeqQpQ/SU= 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: We want to stop special casing hugetlb mappings and make them go through generic channels, so teach arch_get_unmapped_area_{topdown_}vmflags to handle those. x86 specific hugetlb function does not set either info.start_gap or info.align_offset so the same here for compatibility. Signed-off-by: Oscar Salvador --- arch/x86/kernel/sys_x86_64.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c index 87f8c9a71c49..776ae6fa7f2d 100644 --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -25,8 +26,10 @@ /* * Align a virtual address to avoid aliasing in the I$ on AMD F15h. */ -static unsigned long get_align_mask(void) +static unsigned long get_align_mask(struct file *filp) { + if (filp && is_file_hugepages(filp)) + return huge_page_mask_align(filp); /* handle 32- and 64-bit case with a single conditional */ if (va_align.flags < 0 || !(va_align.flags & (2 - mmap_is_ia32()))) return 0; @@ -49,7 +52,7 @@ static unsigned long get_align_mask(void) */ static unsigned long get_align_bits(void) { - return va_align.bits & get_align_mask(); + return va_align.bits & get_align_mask(NULL); } static int __init control_va_addr_alignment(char *str) @@ -148,12 +151,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, info.length = len; info.low_limit = begin; info.high_limit = end; - info.align_offset = pgoff << PAGE_SHIFT; - info.start_gap = stack_guard_placement(vm_flags); + if (!(filp && is_file_hugepages(filp))) { + info.align_offset = pgoff << PAGE_SHIFT; + info.start_gap = stack_guard_placement(vm_flags); + } if (filp) { - info.align_mask = get_align_mask(); + info.align_mask = get_align_mask(filp); info.align_offset += get_align_bits(); } + return vm_unmapped_area(&info); } @@ -199,7 +205,10 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0, info.low_limit = PAGE_SIZE; info.high_limit = get_mmap_base(0); - info.start_gap = stack_guard_placement(vm_flags); + if (!(filp && is_file_hugepages(filp))) { + info.start_gap = stack_guard_placement(vm_flags); + info.align_offset = pgoff << PAGE_SHIFT; + } /* * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area @@ -211,9 +220,8 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0, if (addr > DEFAULT_MAP_WINDOW && !in_32bit_syscall()) info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW; - info.align_offset = pgoff << PAGE_SHIFT; if (filp) { - info.align_mask = get_align_mask(); + info.align_mask = get_align_mask(filp); info.align_offset += get_align_bits(); } addr = vm_unmapped_area(&info); From patchwork Mon Oct 7 07:50:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824290 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 8C32CCFB43F for ; Mon, 7 Oct 2024 07:51:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7217D6B00FB; Mon, 7 Oct 2024 03:50:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51FFB6B00FD; Mon, 7 Oct 2024 03:50:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34C556B00FC; Mon, 7 Oct 2024 03:50:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0EF566B00FA for ; Mon, 7 Oct 2024 03:50:58 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6AEB51214CD for ; Mon, 7 Oct 2024 07:50:57 +0000 (UTC) X-FDA: 82646034954.01.B1CB47C Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf13.hostedemail.com (Postfix) with ESMTP id 6114C2000D for ; Mon, 7 Oct 2024 07:50:55 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf13.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=1728287347; a=rsa-sha256; cv=none; b=ZW1MfX3r01G4Drn/G2x1wcT5GBRQzRegwOD4BM/LgeuLLgz3mAufCmr0NRQT5Hl4iWOpHN VoQflEqP7Q6fHdEMVD/06NUyGqWR852pucW5tNUGCuMyPK+9X0J/lMkJ/sSvsOWUs9YoIL MatfLWCfU+/li/qU7ndooXmtLuL1nbg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf13.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=1728287347; 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; bh=oUUAD68fHlSbJoAEYfh90MZHvvNNjeHrR+6qtFiaE78=; b=1NH0qbrUIIdiD8AwQ6luj+iuX8ciHOeC/oPmA6gaomUvH1bkwoDNassMf5yPwzZeOyN0R4 5t/EWux4N3ez+2CJUQk0DSMUoH8ehkaxCMzOESynpE2dONyuYgvG2K6k7qCq1pnL9GjWFH RzBGoU4e+e0bTGF2IQ0Xgjjl+CNueY8= 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 249B21F8C2; Mon, 7 Oct 2024 07:50:54 +0000 (UTC) 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 7864D132BD; Mon, 7 Oct 2024 07:50:53 +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 sKuJGt2SA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:53 +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 4/9] arch/sparc: Teach arch_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Mon, 7 Oct 2024 09:50:32 +0200 Message-ID: <20241007075037.267650-5-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6114C2000D X-Stat-Signature: p5u4c9hsh3gszycx936m43atmwy4ent7 X-Rspam-User: X-HE-Tag: 1728287455-737803 X-HE-Meta: U2FsdGVkX18MUUEgJ1X7zoviSXkxByF6dg8XU0VES+pGmN+Xo8EW8muif2/ly9ULrYYnU9zP5jzk9YZumetOXAFLJ8G+DinviviZUpq2xk0e5ZYPuhjHk7Udzmh/B+YboW+A9msgGt9+7NTEhu7AUVAGjJ7oczMSLrW0qh1/vw4L0aJr8u8p7n7tLyD/MzWMMPSsEDA7x5weT3rRa8KzoE+1va7OwJpAHJCRrI4gw7tJM4a727XSkakd22cCD6NWMVqUmyc3giM4NEVzAC7f/VXD3tyo23lrzLWgwzJJN2L4v7XyHuZDx1+GM8g4Ci0nbVr9ONw0xayyMRV9W6jFDhE8on3Zsit+Z7/z+CMkROrkX0uGq9w3416JKJ13WxHffCoNMPGkCacthlop16xdaGt4QFxT24ldL8UZ/hymRebcsRtgWErR1MS98RqmJYtTMtzbuX8qs9CV+BecSKZ7mog5hkzZokUutg3MMqlWz72CeKrx1y1p3Jgbv53x0+OXzrZrdHzbW/SzkrHyHdCwcpXZPirrMyw8XhKxq6FmIKBQ75nkOcTJFjU5kHixt9hFaPsZ0N0G+nebB1yuAfx04UNWRv4dZop/EiU85/qh6jODSFB8cDqLqc313gGE9l8C1oyFvk1rIWA+J6OhJibC5VuAE+0+WjfiPt1LLID+WTZ3iSMEyVoyhEZnaU99IfyetliG4bwNPJ4SODi0l81LOphrCJD9IN6sHPRq3WlAcdce6JkUIfqOu2HZBk+Gqo6Z9WbB//g9h3PrXQI/xUsWLGdipwdzMe4nup/PhfgrxSmAQWnT55VftZJJ2NF5xp2NOroc7+iE7YKTQt1PffT9cng/feXQKVGYAJjMkoU6VkmCD3JdZqY5lct225/RLBDvlZfcuobVbdQhBRZ4vQqO9O6RR+QhIuidLKxOzeMsuw9ask2XokojNINHYWPLwWuzV/rlQWUz1woHIjE0klg CDuyrJn9 j+wYxVinKeUeDdAvilVbLPGxUiM+SuNiEoFbKsBwnC6yY9OSiZFq4MG7ak3+uusJ+FEShiT01X9Z1u+vo3o67DAZUa+2SLU+6oHNHNDNuP1HNwrTs9n54lg42uwr/cOrn1cRAdPaSw9Bhggv5nfAe6UTtdHgoMEIllXBdpm67Lk7WcZM= 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: We want to stop special casing hugetlb mappings and make them go through generic channels, so teach arch_get_unmapped_area{_topdown} to handle those. sparc specific hugetlb function does not set info.align_offset, and does not care about adjusting the align_mask for MAP_SHARED cases, so the same here for compatibility. Signed-off-by: Oscar Salvador --- arch/sparc/kernel/sys_sparc_32.c | 17 +++++++++++---- arch/sparc/kernel/sys_sparc_64.c | 37 +++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c index 80822f922e76..fb31bc0c5b48 100644 --- a/arch/sparc/kernel/sys_sparc_32.c +++ b/arch/sparc/kernel/sys_sparc_32.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -42,12 +43,16 @@ SYSCALL_DEFINE0(getpagesize) unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { struct vm_unmapped_area_info info = {}; + bool file_hugepage = false; + + if (filp && is_file_hugepages(filp)) + file_hugepage = true; if (flags & MAP_FIXED) { /* We do not accept a shared mapping if it would violate * cache aliasing constraints. */ - if ((flags & MAP_SHARED) && + if (!file_hugepage && (flags & MAP_SHARED) && ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1))) return -EINVAL; return addr; @@ -62,9 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi info.length = len; info.low_limit = addr; info.high_limit = TASK_SIZE; - info.align_mask = (flags & MAP_SHARED) ? - (PAGE_MASK & (SHMLBA - 1)) : 0; - info.align_offset = pgoff << PAGE_SHIFT; + if (!file_hugepage) { + info.align_mask = (flags & MAP_SHARED) ? + (PAGE_MASK & (SHMLBA - 1)) : 0; + info.align_offset = pgoff << PAGE_SHIFT; + } else { + info.align_mask = huge_page_mask_align(filp); + } return vm_unmapped_area(&info); } diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index acade309dc2f..c5a284df7b41 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -87,6 +88,16 @@ static inline unsigned long COLOR_ALIGN(unsigned long addr, return base + off; } +static unsigned long get_align_mask(struct file *filp, unsigned long flags) +{ + if (filp && is_file_hugepages(filp)) + return huge_page_mask_align(filp); + if (filp || (flags & MAP_SHARED)) + return PAGE_MASK & (SHMLBA - 1); + + return 0; +} + unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags) { struct mm_struct *mm = current->mm; @@ -94,12 +105,16 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi unsigned long task_size = TASK_SIZE; int do_color_align; struct vm_unmapped_area_info info = {}; + bool file_hugepage = false; + + if (filp && is_file_hugepages(filp)) + file_hugepage = true; if (flags & MAP_FIXED) { /* We do not accept a shared mapping if it would violate * cache aliasing constraints. */ - if ((flags & MAP_SHARED) && + if (!file_hugepage && (flags & MAP_SHARED) && ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1))) return -EINVAL; return addr; @@ -111,7 +126,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi return -ENOMEM; do_color_align = 0; - if (filp || (flags & MAP_SHARED)) + if ((filp || (flags & MAP_SHARED)) && !file_hugepage) do_color_align = 1; if (addr) { @@ -129,8 +144,9 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi info.length = len; info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = min(task_size, VA_EXCLUDE_START); - info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; - info.align_offset = pgoff << PAGE_SHIFT; + info.align_mask = get_align_mask(filp, flags); + if (!file_hugepage) + info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) { @@ -154,15 +170,19 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, unsigned long addr = addr0; int do_color_align; struct vm_unmapped_area_info info = {}; + bool file_hugepage = false; /* This should only ever run for 32-bit processes. */ BUG_ON(!test_thread_flag(TIF_32BIT)); + if (filp && is_file_hugepages(filp)) + file_hugepage = true; + if (flags & MAP_FIXED) { /* We do not accept a shared mapping if it would violate * cache aliasing constraints. */ - if ((flags & MAP_SHARED) && + if (!file_hugepage && (flags & MAP_SHARED) && ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1))) return -EINVAL; return addr; @@ -172,7 +192,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, return -ENOMEM; do_color_align = 0; - if (filp || (flags & MAP_SHARED)) + if ((filp || (flags & MAP_SHARED)) && !file_hugepage) do_color_align = 1; /* requesting a specific address */ @@ -192,8 +212,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.length = len; info.low_limit = PAGE_SIZE; info.high_limit = mm->mmap_base; - info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0; - info.align_offset = pgoff << PAGE_SHIFT; + info.align_mask = get_align_mask(filp, flags); + if (!file_hugepage) + info.align_offset = pgoff << PAGE_SHIFT; addr = vm_unmapped_area(&info); /* From patchwork Mon Oct 7 07:50:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824291 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 E6308CFB441 for ; Mon, 7 Oct 2024 07:51:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28E546B00FC; Mon, 7 Oct 2024 03:50:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 179BD6B00FD; Mon, 7 Oct 2024 03:50:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E22186B00FE; Mon, 7 Oct 2024 03:50:58 -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 B9AF76B00FC for ; Mon, 7 Oct 2024 03:50:58 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5A93E161484 for ; Mon, 7 Oct 2024 07:50:58 +0000 (UTC) X-FDA: 82646034996.16.D4A8C86 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf15.hostedemail.com (Postfix) with ESMTP id 2703AA000B for ; Mon, 7 Oct 2024 07:50:55 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jjDvyrXZ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Is+1Jb6y; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jjDvyrXZ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Is+1Jb6y; spf=pass (imf15.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=1728287388; 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=PljpHijC2le6TjcuL38vbgVuWWQAUhtZMhhfqH3Mudw=; b=cW9POUMFQjnqpn+4BVr+S9leRdHOojwBZdTzYF5USL/uZdSvsHpZJEwqoYyxBkM7ENW8sF CEne5cBlDoLeXvsTc3l2I+9bf14irP+FEb4pUxJgGX8I/NGDwWo19rA/REDyezE9pc8Cyv eQtkoNYUP/TB4CBGLQV+ZII8ELRzLDI= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jjDvyrXZ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Is+1Jb6y; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jjDvyrXZ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Is+1Jb6y; spf=pass (imf15.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728287388; a=rsa-sha256; cv=none; b=NcxN0B1Qae3tWEi4BywYcwnR4ARSvehBWZdQXVPf6K+CVqH2iL2NbrMQ78qsT3iXH2eBuh g5Gr94rg43VXODpzu36V0MpOHHDW76lWAWE8XgLKsquyPj6n81bDI7ds6nbsHyJKjPaPAS +uf4ZBk5Cydd9Xpz1P5ldEi2skQt4tU= 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 D800621F3D; Mon, 7 Oct 2024 07:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728287454; 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: in-reply-to:in-reply-to:references:references; bh=PljpHijC2le6TjcuL38vbgVuWWQAUhtZMhhfqH3Mudw=; b=jjDvyrXZLGwRxc+rhEwW0WySw7JheFddYHFILlj3PfC7Y/9i690Lm64tsU5bBkQ46gwGVH /dsv1MVTizOb3LlOBcyDKQfcHu4kRD5rDT1/yl/yAbB4QU3WlxbCQ6IFYE+W+S2H6FosTw /JlR9d4fwEU/BV0lM0sI/ruESP2H/HE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728287454; 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: in-reply-to:in-reply-to:references:references; bh=PljpHijC2le6TjcuL38vbgVuWWQAUhtZMhhfqH3Mudw=; b=Is+1Jb6y0qzHi/vp/JmfqJaQQVmgHUXIKRdJY8ZWMyL7a/Axz1IY3IbojyAKX1mGQF0rb1 Q0cv/yTKNl4NPgAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728287454; 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: in-reply-to:in-reply-to:references:references; bh=PljpHijC2le6TjcuL38vbgVuWWQAUhtZMhhfqH3Mudw=; b=jjDvyrXZLGwRxc+rhEwW0WySw7JheFddYHFILlj3PfC7Y/9i690Lm64tsU5bBkQ46gwGVH /dsv1MVTizOb3LlOBcyDKQfcHu4kRD5rDT1/yl/yAbB4QU3WlxbCQ6IFYE+W+S2H6FosTw /JlR9d4fwEU/BV0lM0sI/ruESP2H/HE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728287454; 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: in-reply-to:in-reply-to:references:references; bh=PljpHijC2le6TjcuL38vbgVuWWQAUhtZMhhfqH3Mudw=; b=Is+1Jb6y0qzHi/vp/JmfqJaQQVmgHUXIKRdJY8ZWMyL7a/Axz1IY3IbojyAKX1mGQF0rb1 Q0cv/yTKNl4NPgAg== 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 380B0132BD; Mon, 7 Oct 2024 07:50:54 +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 GJDPCt6SA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:54 +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 5/9] arch/powerpc: Teach book3s64 arch_get_unmapped_area{_topdown} to handle hugetlb mappings Date: Mon, 7 Oct 2024 09:50:33 +0200 Message-ID: <20241007075037.267650-6-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 2703AA000B X-Stat-Signature: jhnwudhad4o6ittys63mk16dq7cd8zh8 X-HE-Tag: 1728287455-588348 X-HE-Meta: U2FsdGVkX1/JuHgWmtNxcG56/8i0L2AwMtY9mBAOWgT8khQDgL4xAiICQf5MXj877fI3r8lTGQGv7uz+5J71SyFr0ZkeBY8m/yaNpzlA9Mq0OIEEkd4goR5SeHMGKLk83GL2N1YipXBsENZZTJNGrWVC/fpB6vUGDT8irQ2qSnq3kwA4X0+U8X/gSoUrs0JpVMnk5DYkWdiRl8Gyae9TYT1ifdQmTsUoyOoyCgAiJN8X4h1yV0XAewGNac99R3/p/5htspg68iFZs54Xo6xKu57KAteDN9Hl56vM7ex481U9mU3t3ZKfHuxYRYVEuukjfHxkr4WWcswtF84lRfC7ZAKPwM80GdVCjEY0KPj2IlssR2/cBrMsc/9WI4aNkXgg3dgDbt1N3kEoSjXAKgQfl+W/FAb+Q9BWva4m5fI1sEzTjxXnPLSsFdxX2HT+Ego422VIWeoPtLVRIvkGq4ybC7eGyUTtnNB163N7mezT0gzZT2JJXaKCV3A1gDkkXKVw7eZ8jX4rWQKzGC+a2EjxZMsfQVFLSMzujBdlHYcf2kUBTR2xgxY+9YE5RaXwc1QaNj4a/WU8aAIukeVjj/+AGKh6XK8txkSa8fmyBYRyKYUdgPzOQ1Nz6bVozELSm4cMNBYHwyvXzidBZBWif+RgN8g8O9WaUNbYoSUjNwrPg4JpaeklRavqOtTddvfDLR9dQDXoWxcYqfZ87LqCxkLQK2LB44tuAIsIJu5RPMIZj2n7Ilu93d/FfAz3d84Zl+uYY5xsg5S9n3+wOsMyBHaZabkX8Ue/aYeVrdY96ohY+r9nqoVihWf+gWYNA+TWFaPZKSsf7WH/sc9QoE68c3xkZYwGWDyj1fZ3px7yXBuJKWJxeVdu2lfyCesg9DgoXyzS4C1xymB0G4y7Hgfq0l7LApCl3BEY2f9VjRts/Bdn5dscIzfyLveECE4kWlwx/oQME2HzZlmJBPN0VN08HgF Swz7X/W5 4IgxRk3YzDSDf0Mv5COaOOZxNjRHhxov2wnwj1jhDARHhybWb5WTeMWv3FoR8eeEgrJARwTEy6NnzjkjX5aYG1pb12qWKpCpcj1ioszjdDuMFtKmBYMsyUYEX08ZeLdPQ6DYVefAHMb0QH82EaIHsUCMu6ZHhwS+wH4kLHrGKSr5G7q7JlxhM3/VmkW2GdvYMAkB1XdCYmJBKjrGXD8VjHHkrrY4epJmZ3VwwqHGaGfes0utw2WD6dmRmwwXaUXgrFbSmtFAkN5GZuMqbqUme/XsDvRWqdZ7vLtBI42Pwa7lbrKOxw2/aaZRIRQ== 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: We want to stop special casing hugetlb mappings and make them go through generic channels, so teach arch_get_unmapped_area{_topdown} to handle those. Reshuffle file_to_psize() definition so arch_get_unmapped_area{_topdown} can make use of it. Signed-off-by: Oscar Salvador --- arch/powerpc/mm/book3s64/slice.c | 40 ++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index 87307d0fc3b8..3a858f6b7270 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -633,6 +633,20 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, } EXPORT_SYMBOL_GPL(slice_get_unmapped_area); +#ifdef CONFIG_HUGETLB_PAGE +static int file_to_psize(struct file *file) +{ + struct hstate *hstate = hstate_file(file); + + return shift_to_mmu_psize(huge_page_shift(hstate)); +} +#else +static int file_to_psize(struct file *file) +{ + return 0; +} +#endif + unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, @@ -640,11 +654,17 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long flags, vm_flags_t vm_flags) { + unsigned int psize; + if (radix_enabled()) return generic_get_unmapped_area(filp, addr, len, pgoff, flags, vm_flags); - return slice_get_unmapped_area(addr, len, flags, - mm_ctx_user_psize(¤t->mm->context), 0); + if (filp && is_file_hugepages(filp)) + psize = file_to_psize(filp); + else + psize = mm_ctx_user_psize(¤t->mm->context); + + return slice_get_unmapped_area(addr, len, flags, psize, 0); } unsigned long arch_get_unmapped_area_topdown(struct file *filp, @@ -654,11 +674,17 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, const unsigned long flags, vm_flags_t vm_flags) { + unsigned int psize; + if (radix_enabled()) return generic_get_unmapped_area_topdown(filp, addr0, len, pgoff, flags, vm_flags); - return slice_get_unmapped_area(addr0, len, flags, - mm_ctx_user_psize(¤t->mm->context), 1); + if (filp && is_file_hugepages(filp)) + psize = file_to_psize(filp); + else + psize = mm_ctx_user_psize(¤t->mm->context); + + return slice_get_unmapped_area(addr0, len, flags, psize, 1); } unsigned int notrace get_slice_psize(struct mm_struct *mm, unsigned long addr) @@ -789,12 +815,6 @@ unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); } -static int file_to_psize(struct file *file) -{ - struct hstate *hstate = hstate_file(file); - return shift_to_mmu_psize(huge_page_shift(hstate)); -} - unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) From patchwork Mon Oct 7 07:50:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824292 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 35C91CFB43F for ; Mon, 7 Oct 2024 07:51:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E994B6B00FD; Mon, 7 Oct 2024 03:50:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E20CB6B00FE; Mon, 7 Oct 2024 03:50:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C74F76B00FF; Mon, 7 Oct 2024 03:50:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9D94B6B00FD for ; Mon, 7 Oct 2024 03:50:59 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1C5B1161484 for ; Mon, 7 Oct 2024 07:50:59 +0000 (UTC) X-FDA: 82646035038.30.23E6A08 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf27.hostedemail.com (Postfix) with ESMTP id 00F894001B for ; Mon, 7 Oct 2024 07:50:56 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf27.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=1728287432; a=rsa-sha256; cv=none; b=QxsC/ocAIkZAxJ87QBRLFO9fHXP87uHAvFnm6CzbJoIrAtzrA6fH7TTkhqBSypyl3Yesh+ COttgta0bdM4/ADLuToHxnMFPjJnv/jL3Mhniv65KS31zBKCSTTAgZVABw8i782QfDDP0r VAJaZWtD8APoyrq/IZ+neEo7eY4bOe4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf27.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=1728287432; 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; bh=M4NF0V/6zll6/XXedmKrJjb2YRT81sYU+Jdnzk66xVM=; b=4bIkSzooSfNqCIfS5OjlzQDwcKHcfDAAro6U6B7qRip5+xsYf8+++PjqR1xoD5Jr8m3naa 1bgpADVZpY5HOH6wlcEZLYQJJZLlBovn7cdPojpiOZ37ZL+KoKOa0bifcmDsrQK443OgmR TKpFWFEkWVr/jw80XoQEc6RLlxYY8Lc= 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 AE63E1FD18; Mon, 7 Oct 2024 07:50:55 +0000 (UTC) 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 EB9AC13A55; Mon, 7 Oct 2024 07:50:54 +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 oMimNt6SA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:54 +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 6/9] mm: Make hugetlb mappings go through mm_get_unmapped_area_vmflags Date: Mon, 7 Oct 2024 09:50:34 +0200 Message-ID: <20241007075037.267650-7-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspam-User: X-Stat-Signature: weoiz7c96tsggm56zq9u4b7f41mjcg7x X-Rspamd-Queue-Id: 00F894001B X-Rspamd-Server: rspam02 X-HE-Tag: 1728287456-777711 X-HE-Meta: U2FsdGVkX19oW6T0BiDJIFTeg47CFcAbRx9u4QAby9vXImOcg46gBE+lO/rCleCL5bS93n6XUN+oaaPPpUI4VNeDOHDxTxRDW6+TRIQhyeoenlbKFp/iTnto0JhpAqhICkL0dhkggkVKiYh1FDHiFkOKc7MUuz6SyPCV4gCvu03V8UuPG6AfTGoR3Ooj3N6OwXifpmvUdempCxHkBSh45x3j6vdItuLI8PPzCcwn+Lvx0NFMOMKqYyinE1pfMWhss0tuMeu35xkbvK6bcGVPIygRwQKeuGwvLNpxhNt4XYobV002QZypkGqvAWMu3ycw3NGd2DNT02sAuuZFq9Qe/u7G6Id5j+GQptU26D0z1ZlSvkW/eTcqHrmKloIFVVjFlJaSJ23faPmivbF9jrfC1AIdUTxOpeSsf/XlVUL8HETffdeJ5/jHXC0gl4uSbXkwzAI5hzZgRDXoBZyIPaKHmevIY5VZgBUNMEtz9ovcHVeo/AuOsaRu5PMopqeEE6cn7lS7+zfBZT7oNiclFZKL/sLqqQvjuVYtwVMmHDO9H4XlkbS+Kej7M7NkA4BZrMm46oXoIHpGPU+zsxxp8zaQXLvvYSP+J3UG83ojjNrfy/tV/73NNiv+uO9s8q7ZS7xaXYgZrup7CnbXLw8FyFIxm4B+dP6ueQnfeqjZydymLtZmgpPoFkkif/d+fCYpC8drOZGFTGLfxO5Kxsi5nZV/VHTZHNdBisKIXOCPYboSG2yEfqtk1Ze0hYod0U/fwNenzLMt3giCm2ElkkzitdctXbc9eUf2wkgCcWP/YxAU3vehjfXgHaC6WV4kpGfKHFYLbU8fYNjG45JEi0qmSY2GL2F+DVLFllwlkV8i42xT5r/PmjziFzkkjSR0/RKjAmspk7ihFsYOlpJ6fGpecv7WH8RSlMNQlkF/r4p+BPRutNw3reXVZZsQUG96vcS1VW19ZAddyX3/W3Icfp1ilSR BYcSEu+q Vtf2ZHM+kR8hAs7zCxR17qZFrUJvYGE5qt2YcSBA1jZVfm419+A1JMaRWoinlUSIyzHqegMBnQLitC+FLSurPOmQwr7tq7lUftn7Z0PVIhOS55Z8H+oO5SNLGxNN3AF1TGoqz0YGUCzwK1jRKFVtDGlTr1krFU/8T4LvAOt5PUF3GxhY= 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: Hugetlb mappings will no longer be special cased but rather go through the generic mm_get_unmapped_area_vmflags function. For that to happen, let us remove the .get_unmapped_area from hugetlbfs_file_operations struct, and hint __get_unmapped_area that it should not send hugetlb mappings through thp_get_unmapped_area_vmflags but through mm_get_unmapped_area_vmflags. Create also a function called hugetlb_mmap_check_and_align() where a couple of safety checks are being done and the addr is aligned to the huge page size. Otherwise we will have to do this in every single function, which duplicates quite a lot of code. Signed-off-by: Oscar Salvador --- fs/hugetlbfs/inode.c | 24 ++++++++++++++++-------- include/linux/hugetlb.h | 9 ++++----- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 5cf327337e22..2c5f34e315d2 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -258,15 +258,23 @@ generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, pgoff, flags); } -#ifndef HAVE_ARCH_HUGETLB_UNMAPPED_AREA -static unsigned long -hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) +unsigned long +__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long flags) { - return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); + unsigned long addr0 = 0; + struct hstate *h = hstate_file(file); + + if (len & ~huge_page_mask(h)) + return -EINVAL; + if ((flags & MAP_FIXED) && prepare_hugepage_range(file, addr, len)) + return -EINVAL; + if (addr) + addr0 = ALIGN(addr, huge_page_size(h)); + + return mm_get_unmapped_area_vmflags(current->mm, file, addr, len, pgoff, + flags, 0); } -#endif /* * Someone wants to read @bytes from a HWPOISON hugetlb @page from @offset. @@ -1300,7 +1308,7 @@ static const struct file_operations hugetlbfs_file_operations = { .read_iter = hugetlbfs_read_iter, .mmap = hugetlbfs_file_mmap, .fsync = noop_fsync, - .get_unmapped_area = hugetlb_get_unmapped_area, + .get_unmapped_area = __hugetlb_get_unmapped_area, .llseek = default_llseek, .fallocate = hugetlbfs_fallocate, .fop_flags = FOP_HUGE_PAGES, diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 368d552e4860..3a81b6126f62 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -546,11 +546,10 @@ static inline struct hstate *hstate_inode(struct inode *i) } #endif /* !CONFIG_HUGETLBFS */ -#ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA -unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags); -#endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */ +unsigned long +__generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags); unsigned long generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, From patchwork Mon Oct 7 07:50:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824293 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 A3D0BCFB441 for ; Mon, 7 Oct 2024 07:51:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B69D6B00B1; Mon, 7 Oct 2024 03:51:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 965986B00B2; Mon, 7 Oct 2024 03:51:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 683756B00AE; Mon, 7 Oct 2024 03:51:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2EE096B007B for ; Mon, 7 Oct 2024 03:51:00 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EB2EF415B1 for ; Mon, 7 Oct 2024 07:50:59 +0000 (UTC) X-FDA: 82646035038.17.D23B0EF Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf21.hostedemail.com (Postfix) with ESMTP id D13581C0016 for ; Mon, 7 Oct 2024 07:50:57 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pCbffnnO; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yeHAAvDP; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pCbffnnO; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yeHAAvDP; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf21.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=1728287359; a=rsa-sha256; cv=none; b=tWINzrzm2U/RaMsMllQfzNal2+J9UaQDcfZVlm8sb6pgcXGngUsAofmIQz3/cKMrwluE3T Iaxkf/Ko1tJViEZiKc33+XTz38+UYHwdNylyxV+6B2UCbDIKbfypdgcAbVS0bASh4PuYn+ iRsM5QugZW710Ao6AqDnfkhHZjr/oIY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pCbffnnO; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yeHAAvDP; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pCbffnnO; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=yeHAAvDP; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf21.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=1728287359; 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=BOWmyOrUA49R+sE8zSPv6nz1xxCqaVW3asR97FSYM6k=; b=lqmA6HREMBg2Yibn1pbM2qgzey2einK2KqHkgKLOXCMdiznfhfkaz4EP/LSQbOyzMjRWul 1pnW9i9FsVKPmWX3CvWFPBdgJqKUrpB+Dsav5MLmCVDBpxGbLoPLRUSqy5J9Ci6l9k2/+K UDkpNzCpSyW0L90U9pJOzEZ3QP9eksw= 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-out2.suse.de (Postfix) with ESMTPS id 6C4F11FD19; Mon, 7 Oct 2024 07:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728287456; 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: in-reply-to:in-reply-to:references:references; bh=BOWmyOrUA49R+sE8zSPv6nz1xxCqaVW3asR97FSYM6k=; b=pCbffnnOCFTSKXs4J8B/LuqPT8kBLJXmfQmr2BaL66TTeQXzIaQFcaIMcB+P0aXYWGNf7b I0s6EApTHE6em5yJfPkARghd9VLNHiYpUtW6fVcS2dStoI/Q/7DYIU6WIM4waYcAOIOMaU 5xjEr/0pxAXlTKW40KmyXtC/BseUD5I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728287456; 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: in-reply-to:in-reply-to:references:references; bh=BOWmyOrUA49R+sE8zSPv6nz1xxCqaVW3asR97FSYM6k=; b=yeHAAvDPTOQz2A2QfB9YcyolhAigtelpmsrZWnPsTJ/2buFmBF7G7ZHa0ZsGVx82FFI7C2 xSHcz+noKVsm2/Bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1728287456; 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: in-reply-to:in-reply-to:references:references; bh=BOWmyOrUA49R+sE8zSPv6nz1xxCqaVW3asR97FSYM6k=; b=pCbffnnOCFTSKXs4J8B/LuqPT8kBLJXmfQmr2BaL66TTeQXzIaQFcaIMcB+P0aXYWGNf7b I0s6EApTHE6em5yJfPkARghd9VLNHiYpUtW6fVcS2dStoI/Q/7DYIU6WIM4waYcAOIOMaU 5xjEr/0pxAXlTKW40KmyXtC/BseUD5I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1728287456; 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: in-reply-to:in-reply-to:references:references; bh=BOWmyOrUA49R+sE8zSPv6nz1xxCqaVW3asR97FSYM6k=; b=yeHAAvDPTOQz2A2QfB9YcyolhAigtelpmsrZWnPsTJ/2buFmBF7G7ZHa0ZsGVx82FFI7C2 xSHcz+noKVsm2/Bw== 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 BDB4D132BD; Mon, 7 Oct 2024 07:50:55 +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 6M5oK9+SA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:55 +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 7/9] mm: Drop hugetlb_get_unmapped_area{_*} functions Date: Mon, 7 Oct 2024 09:50:35 +0200 Message-ID: <20241007075037.267650-8-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: D13581C0016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: z9p8xiwzzd4k1u18q9moph9g7uqcp4rw X-HE-Tag: 1728287457-516158 X-HE-Meta: U2FsdGVkX1+kDET7kRdbm7+KUPPCEzcx344ovlyReySgQJOrHtnbCXNimECJj0IlW50djnUbT3H+e5FORYJo5ooAiEa2JcHfnOoA1ngORDWHu8BiGvBr5Zm8x3gYG3LVQJMdI4l5eBUV25BBFQ/VcZ56sfzd9CqGc/uhZK8dNRg4rd0ZrEQAiDhtSHCLX1Kha5HAUgP6jO2znO4kYyHg9ypCTIqfmGLRe0c2AIS2s7DTaGyVVdQXQW51TZGTBk43OpwgGXuURrGTdyjYgB3Ut0c4Fi8cAVuUDQSolHLdMQiXczSwV2f22EruF+zqAIsQRLszRdwkESCxik36evqDJ4MLQsq8P5RBxIb5a+veQAP2kbBdnzBcE2NFKIGfYo5bymMkw0a8PKEbopkx+Q4neOjFJHtM1NC5e6F8aPlfaZgH6mLCDmZc1wpXtoDo/J02OGP3fhZ9fLS6dfaFpVHXFqKMd4oNq3geAsdlBe6oDpr0fGSYZIkq84Y2uVESdFANDYnscNo5Os0d+TieHmwW5YjFRvzmLNhwvJiQdncA01OYBbzBhGDK2GMKjyoq5I2N1J8CKY5mZ+i7TwAVqYuSrKa+Tzo5mYCPwJVQv0QW8tzqJFpOeVrYqOW/5oCMWa0Uyt+VP5oylGVXL1xS2nVitA9Uriy5zhpsJ/X7jkWAq86ISyazhnCxyHv8LMcQu+c10PwFjIHPYxJpvTcevS9DE/v101/qyeNiB3oq+Kp4DcdUQO2dZWJnWtUSsOE5VIf2DGau+hX+B1znmscx3g/P7Pp0pa1u7gj+7BUGmwi+gGkEQgKnd0Oh9D4njvEh5tFl7dTLbwxbn8LCGzRSnMypLltGk3TawGKFg+I7xc//1p0SMlamM/81pZChRduPNTkqpz92mXsY5cCPMnSGhDHtoP3UMn/JyJ6jbl1U3ibGZgD7Ndp970OL/3rfX/fRSJt1Ij/lWCg/ZSipE6RdyH7 h7pZM1+c QVM1Cd0ouktEQlU4KiT/svomnIlhM6rpV9SlQpR0UIpSiuJ05djS0aRgDEh8FpCMekQzYW+/Orayhbva2iqK2MzeL678Nn1uXpHP1RXWOyeaXVYTbhcWt5kb7mih9ELihEz1vRJ8gHdYsPh4kkMDULO1O+V6vkf5ImWiDxUTGdqq5FEyJFRl82mKEh5RUxeAXLWLJ0shXBQ6vCX7Q5d1unqyZqXXu5JAoNMZTEQulqXHxESZIIghloy82lgRU/SdYhiCtmxloDt1wTKcVxeVHKNUcoMw4dFSM0Vi+L7r6zzWB9up8T17k8Cd40g== 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: Hugetlb mappings are now handled through normal channels just like any other mapping, so we no longer need hugetlb_get_unmapped_area* specific functions. Signed-off-by: Oscar Salvador --- arch/parisc/mm/hugetlbpage.c | 21 ------ arch/powerpc/mm/book3s64/slice.c | 10 --- arch/s390/mm/hugetlbpage.c | 85 ------------------------ arch/sparc/mm/hugetlbpage.c | 108 ------------------------------- arch/x86/mm/hugetlbpage.c | 101 ----------------------------- fs/hugetlbfs/inode.c | 96 ++------------------------- include/linux/hugetlb.h | 7 +- 7 files changed, 6 insertions(+), 422 deletions(-) diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c index aa664f7ddb63..e9d18cf25b79 100644 --- a/arch/parisc/mm/hugetlbpage.c +++ b/arch/parisc/mm/hugetlbpage.c @@ -21,27 +21,6 @@ #include -unsigned long -hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (len > TASK_SIZE) - return -ENOMEM; - - if (flags & MAP_FIXED) - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - - if (addr) - addr = ALIGN(addr, huge_page_size(h)); - - /* we need to make sure the colouring is OK */ - return arch_get_unmapped_area(file, addr, len, pgoff, flags, 0); -} pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, diff --git a/arch/powerpc/mm/book3s64/slice.c b/arch/powerpc/mm/book3s64/slice.c index 3a858f6b7270..bc9a39821d1c 100644 --- a/arch/powerpc/mm/book3s64/slice.c +++ b/arch/powerpc/mm/book3s64/slice.c @@ -814,14 +814,4 @@ unsigned long vma_mmu_pagesize(struct vm_area_struct *vma) return 1UL << mmu_psize_to_shift(get_slice_psize(vma->vm_mm, vma->vm_start)); } - -unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - if (radix_enabled()) - return generic_hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); - - return slice_get_unmapped_area(addr, len, flags, file_to_psize(file), 1); -} #endif diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index ded0eff58a19..7c79cf1bc7d7 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -242,88 +242,3 @@ bool __init arch_hugetlb_valid_size(unsigned long size) else return false; } - -static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, - unsigned long addr, unsigned long len, - unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct vm_unmapped_area_info info = {}; - - info.length = len; - info.low_limit = current->mm->mmap_base; - info.high_limit = TASK_SIZE; - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - return vm_unmapped_area(&info); -} - -static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file, - unsigned long addr0, unsigned long len, - unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct vm_unmapped_area_info info = {}; - unsigned long addr; - - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = PAGE_SIZE; - info.high_limit = current->mm->mmap_base; - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - addr = vm_unmapped_area(&info); - - /* - * A failed mmap() very likely causes application failure, - * so fall back to the bottom-up function here. This scenario - * can happen with large stack limits and large mmap() - * allocations. - */ - if (addr & ~PAGE_MASK) { - VM_BUG_ON(addr != -ENOMEM); - info.flags = 0; - info.low_limit = TASK_UNMAPPED_BASE; - info.high_limit = TASK_SIZE; - addr = vm_unmapped_area(&info); - } - - return addr; -} - -unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (len > TASK_SIZE - mmap_min_addr) - return -ENOMEM; - - if (flags & MAP_FIXED) { - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - goto check_asce_limit; - } - - if (addr) { - addr = ALIGN(addr, huge_page_size(h)); - vma = find_vma(mm, addr); - if (TASK_SIZE - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma))) - goto check_asce_limit; - } - - if (!test_bit(MMF_TOPDOWN, &mm->flags)) - addr = hugetlb_get_unmapped_area_bottomup(file, addr, len, - pgoff, flags); - else - addr = hugetlb_get_unmapped_area_topdown(file, addr, len, - pgoff, flags); - if (offset_in_page(addr)) - return addr; - -check_asce_limit: - return check_asce_limit(mm, addr, len); -} diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index cc91ca7a1e18..eee601a0d2cf 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -19,114 +19,6 @@ #include #include -/* Slightly simplified from the non-hugepage variant because by - * definition we don't have to worry about any page coloring stuff - */ - -static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp, - unsigned long addr, - unsigned long len, - unsigned long pgoff, - unsigned long flags) -{ - struct hstate *h = hstate_file(filp); - unsigned long task_size = TASK_SIZE; - struct vm_unmapped_area_info info = {}; - - if (test_thread_flag(TIF_32BIT)) - task_size = STACK_TOP32; - - info.length = len; - info.low_limit = TASK_UNMAPPED_BASE; - info.high_limit = min(task_size, VA_EXCLUDE_START); - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - addr = vm_unmapped_area(&info); - - if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) { - VM_BUG_ON(addr != -ENOMEM); - info.low_limit = VA_EXCLUDE_END; - info.high_limit = task_size; - addr = vm_unmapped_area(&info); - } - - return addr; -} - -static unsigned long -hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, - const unsigned long len, - const unsigned long pgoff, - const unsigned long flags) -{ - struct hstate *h = hstate_file(filp); - struct mm_struct *mm = current->mm; - unsigned long addr = addr0; - struct vm_unmapped_area_info info = {}; - - /* This should only ever run for 32-bit processes. */ - BUG_ON(!test_thread_flag(TIF_32BIT)); - - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = PAGE_SIZE; - info.high_limit = mm->mmap_base; - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - addr = vm_unmapped_area(&info); - - /* - * A failed mmap() very likely causes application failure, - * so fall back to the bottom-up function here. This scenario - * can happen with large stack limits and large mmap() - * allocations. - */ - if (addr & ~PAGE_MASK) { - VM_BUG_ON(addr != -ENOMEM); - info.flags = 0; - info.low_limit = TASK_UNMAPPED_BASE; - info.high_limit = STACK_TOP32; - addr = vm_unmapped_area(&info); - } - - return addr; -} - -unsigned long -hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - unsigned long task_size = TASK_SIZE; - - if (test_thread_flag(TIF_32BIT)) - task_size = STACK_TOP32; - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (len > task_size) - return -ENOMEM; - - if (flags & MAP_FIXED) { - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - return addr; - } - - if (addr) { - addr = ALIGN(addr, huge_page_size(h)); - vma = find_vma(mm, addr); - if (task_size - len >= addr && - (!vma || addr + len <= vm_start_gap(vma))) - return addr; - } - if (!test_bit(MMF_TOPDOWN, &mm->flags)) - return hugetlb_get_unmapped_area_bottomup(file, addr, len, - pgoff, flags); - else - return hugetlb_get_unmapped_area_topdown(file, addr, len, - pgoff, flags); -} static pte_t sun4u_hugepage_shift_to_tte(pte_t entry, unsigned int shift) { diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index 807a5859a3c4..58f7f2bd535d 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c @@ -19,107 +19,6 @@ #include #include -#ifdef CONFIG_HUGETLB_PAGE -static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, - unsigned long addr, unsigned long len, - unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct vm_unmapped_area_info info = {}; - - info.length = len; - info.low_limit = get_mmap_base(1); - - /* - * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area - * in the full address space. - */ - info.high_limit = in_32bit_syscall() ? - task_size_32bit() : task_size_64bit(addr > DEFAULT_MAP_WINDOW); - - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - return vm_unmapped_area(&info); -} - -static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file, - unsigned long addr, unsigned long len, - unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct vm_unmapped_area_info info = {}; - - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = PAGE_SIZE; - info.high_limit = get_mmap_base(0); - - /* - * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area - * in the full address space. - */ - if (addr > DEFAULT_MAP_WINDOW && !in_32bit_syscall()) - info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW; - - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - addr = vm_unmapped_area(&info); - - /* - * A failed mmap() very likely causes application failure, - * so fall back to the bottom-up function here. This scenario - * can happen with large stack limits and large mmap() - * allocations. - */ - if (addr & ~PAGE_MASK) { - VM_BUG_ON(addr != -ENOMEM); - info.flags = 0; - info.low_limit = TASK_UNMAPPED_BASE; - info.high_limit = TASK_SIZE_LOW; - addr = vm_unmapped_area(&info); - } - - return addr; -} - -unsigned long -hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - - if (len & ~huge_page_mask(h)) - return -EINVAL; - - if (len > TASK_SIZE) - return -ENOMEM; - - /* No address checking. See comment at mmap_address_hint_valid() */ - if (flags & MAP_FIXED) { - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - return addr; - } - - if (addr) { - addr &= huge_page_mask(h); - if (!mmap_address_hint_valid(addr, len)) - goto get_unmapped_area; - - vma = find_vma(mm, addr); - if (!vma || addr + len <= vm_start_gap(vma)) - return addr; - } - -get_unmapped_area: - if (!test_bit(MMF_TOPDOWN, &mm->flags)) - return hugetlb_get_unmapped_area_bottomup(file, addr, len, - pgoff, flags); - else - return hugetlb_get_unmapped_area_topdown(file, addr, len, - pgoff, flags); -} -#endif /* CONFIG_HUGETLB_PAGE */ #ifdef CONFIG_X86_64 bool __init arch_hugetlb_valid_size(unsigned long size) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 2c5f34e315d2..935c0ed3aa1e 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -171,96 +171,10 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) * Called under mmap_write_lock(mm). */ -static unsigned long -hugetlb_get_unmapped_area_bottomup(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct vm_unmapped_area_info info = {}; - - info.length = len; - info.low_limit = current->mm->mmap_base; - info.high_limit = arch_get_mmap_end(addr, len, flags); - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - return vm_unmapped_area(&info); -} - -static unsigned long -hugetlb_get_unmapped_area_topdown(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, unsigned long flags) -{ - struct hstate *h = hstate_file(file); - struct vm_unmapped_area_info info = {}; - - info.flags = VM_UNMAPPED_AREA_TOPDOWN; - info.length = len; - info.low_limit = PAGE_SIZE; - info.high_limit = arch_get_mmap_base(addr, current->mm->mmap_base); - info.align_mask = PAGE_MASK & ~huge_page_mask(h); - addr = vm_unmapped_area(&info); - - /* - * A failed mmap() very likely causes application failure, - * so fall back to the bottom-up function here. This scenario - * can happen with large stack limits and large mmap() - * allocations. - */ - if (unlikely(offset_in_page(addr))) { - VM_BUG_ON(addr != -ENOMEM); - info.flags = 0; - info.low_limit = current->mm->mmap_base; - info.high_limit = arch_get_mmap_end(addr, len, flags); - addr = vm_unmapped_area(&info); - } - - return addr; -} - -unsigned long -generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma, *prev; - struct hstate *h = hstate_file(file); - const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (len > mmap_end - mmap_min_addr) - return -ENOMEM; - - if (flags & MAP_FIXED) { - if (prepare_hugepage_range(file, addr, len)) - return -EINVAL; - return addr; - } - - if (addr) { - addr = ALIGN(addr, huge_page_size(h)); - vma = find_vma_prev(mm, addr, &prev); - if (mmap_end - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma)) && - (!prev || addr >= vm_end_gap(prev))) - return addr; - } - - /* - * Use MMF_TOPDOWN flag as a hint to use topdown routine. - * If architectures have special needs, they should define their own - * version of hugetlb_get_unmapped_area. - */ - if (test_bit(MMF_TOPDOWN, &mm->flags)) - return hugetlb_get_unmapped_area_topdown(file, addr, len, - pgoff, flags); - return hugetlb_get_unmapped_area_bottomup(file, addr, len, - pgoff, flags); -} - unsigned long -__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long flags) +hugetlb_get_unmapped_area(struct file *file, unsigned long addr, + unsigned long len, unsigned long pgoff, + unsigned long flags) { unsigned long addr0 = 0; struct hstate *h = hstate_file(file); @@ -272,7 +186,7 @@ __hugetlb_get_unmapped_area(struct file *file, unsigned long addr, if (addr) addr0 = ALIGN(addr, huge_page_size(h)); - return mm_get_unmapped_area_vmflags(current->mm, file, addr, len, pgoff, + return mm_get_unmapped_area_vmflags(current->mm, file, addr0, len, pgoff, flags, 0); } @@ -1308,7 +1222,7 @@ static const struct file_operations hugetlbfs_file_operations = { .read_iter = hugetlbfs_read_iter, .mmap = hugetlbfs_file_mmap, .fsync = noop_fsync, - .get_unmapped_area = __hugetlb_get_unmapped_area, + .get_unmapped_area = hugetlb_get_unmapped_area, .llseek = default_llseek, .fallocate = hugetlbfs_fallocate, .fop_flags = FOP_HUGE_PAGES, diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 3a81b6126f62..ae4fe8615bb6 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -547,15 +547,10 @@ static inline struct hstate *hstate_inode(struct inode *i) #endif /* !CONFIG_HUGETLBFS */ unsigned long -__generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, +hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); -unsigned long -generic_hugetlb_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags); - /* * huegtlb page specific state flags. These flags are located in page.private * of the hugetlb head page. Functions created via the below macros should be From patchwork Mon Oct 7 07:50:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824294 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 880D5CFB440 for ; Mon, 7 Oct 2024 07:51:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D5406B00FE; Mon, 7 Oct 2024 03:51:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45D156B00FF; Mon, 7 Oct 2024 03:51:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23B426B0100; Mon, 7 Oct 2024 03:51:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F3BDC6B00FE for ; Mon, 7 Oct 2024 03:51:00 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8F4B21214CD for ; Mon, 7 Oct 2024 07:51:00 +0000 (UTC) X-FDA: 82646035080.14.E62206B Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf10.hostedemail.com (Postfix) with ESMTP id 6F836C0016 for ; Mon, 7 Oct 2024 07:50:58 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.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=1728287391; 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; bh=6OIoAiN9nOueoZEX73u0hngexjQZA0el6oyXMnOmQQw=; b=nGDgQFYsEUIj870KYPT3me9M7GDuhok6ueS8kPpBPTUpiwYMucGPEIHbQDr81uvqFHTBaU 1sKSQoI58tsiMKo9FNV90XO4KhoRjVjS7XoSy8Uem1yl5jYq+I36TXewHlPujiDYRFSqAi ZNb70mkj0TrOLC/9x7pqCT9ZI1cpp9o= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.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=1728287391; a=rsa-sha256; cv=none; b=Zo0bCWOmxXel3fTq8tEiZ9vRW9dHyHpNpc7cTFGbUGLVGZeaEphcU2vxz6ba44oxwYaTS0 BUzzsva7fVYrjWBPaJjW7ZQ43iDL4TTsXcZ/0SMpaRKoFfLZkXsIoJDBUmyq6Z4FhUq21R 41OikUpqdusNOWBliXZcY3nrqkP2c8k= 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 2D19F1FD1A; Mon, 7 Oct 2024 07:50:57 +0000 (UTC) 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 80B4D13A55; Mon, 7 Oct 2024 07:50:56 +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 uBSPHOCSA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:56 +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 8/9] arch/s390: Clean up hugetlb definitions Date: Mon, 7 Oct 2024 09:50:36 +0200 Message-ID: <20241007075037.267650-9-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 6F836C0016 X-Stat-Signature: jb7t13tgjx9wnhhf4q4mty8x4spo9x8a X-HE-Tag: 1728287458-698461 X-HE-Meta: U2FsdGVkX1+TNpND+8R/d/0dlmQh5FRZQTwkNTTqRI8/ixUKTIcd4ac+fo9OxLWscVBDW3+s3BcjnUqL9JkPkiDO2aNZVNf5AYzaEWPUMaFW+xQWf9i7T8hqIV6BVn0kvNBSgPG9VWlqwTUTER04ArTWe5eHL/6kjELiZStvlo0PgQ1HHpkWrMLmI7kVnAVpefQRjqbUzQyC61l/66P8IoHWfXaW5uA46bSeA6bgA5iV8TQgQhuKSqVbuiqsD9+Phj2p3XadKBjd7yD45uD1bLtxdIOMRrIEFfLcokNVngDOq81i8G0FmFNINEOXsHVOTA1uvvup1uL1WgS0GnpbtYAQumFWYFimnqGv4fehk4yK3SxiljGCGFXH4qybQAXKNmJ93kD/Ixk3tGkTya0juzxBzEMz8dELUNsxXYuFWYXl0y5+rMQGrcJU9O2xUA6vyESA5eRdJVTC0Xv/Rt1++F9g+N9SGUvWRZzrZv05aBKHU02Njj1NhYoV4zchdgR0o+fAo3cXSquseMyv98GtQq9BZFYwv/DeHgHCt4CPlbKQFOPIl/db5xbnXiAWrV5FxeKTSi6xzDNlpJDJ7DsAVSik58Q5ckUwmq+tcxQobUumuKtq9iKKAZmhU7II0qRAvVvbT6eum69Yxgk3yZHZM3T0dddpsvJ/keZOVBVmg8+e8TGMiamNPYcevCx1dDPtfmJppgjDhaJI5XbvEn4OAiXpXjVxzATaqi6PACsE+JfoOomTgk7x0pkIMTUevuZyJsJdJTEcfsP+zfoI/S5ulGJCUCYF3A6yAvswe+CoJeeOo5It9pK9ykpbQvDss33pyNHrPRvifRadCQDMYhOCK+sRdFHDD6MhEu69JyV6W7rbZiESsrn6iYZrOCfd2nH2A+UCSaD+/ZxWHVPu2LKFRJm37VwRHXHkGbw0X7HYDsQ4JD4ah29/tXZqDzzEUVra21/z3CCbZvNS9gp+zj7 r3Cq2AaT m3jj4ud19DZLAzC0+EHGJ2mgyQm9q9zNQa55prpyLI1tkvIfLuNJlsp6Q5z4cxMb8hio7JGjAqKdkZfGiASeOGZxhGV3eHjd/rwiKLMFUE/SujABXDo+4+93yFxe+26XskA6b 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: s390 redefines functions that are already defined (and the same) in include/asm-generic/hugetlb.h. Do as the other architectures: 1) include include/asm-generic/hugetlb.h 2) drop the already defined functions in the generic hugetlb.h and 3) use the __HAVE_ARCH_HUGE_* macros to define our own. This gets rid of quite some code. Signed-off-by: Oscar Salvador --- arch/s390/include/asm/hugetlb.h | 58 +++++++++------------------------ include/asm-generic/hugetlb.h | 8 +++++ 2 files changed, 24 insertions(+), 42 deletions(-) diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index cf1b5d6fb1a6..37e80a32623a 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -12,21 +12,24 @@ #include #include -#define hugetlb_free_pgd_range free_pgd_range #define hugepages_supported() (MACHINE_HAS_EDAT1) +#define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, unsigned long sz); void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte); -pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep); -pte_t huge_ptep_get_and_clear(struct mm_struct *mm, +#define __HAVE_ARCH_HUGE_PTEP_GET +extern pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep); +#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR +extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); /* * If the arch doesn't supply something else, assume that hugepage * size aligned regions are ok without further preparation. */ +#define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE static inline int prepare_hugepage_range(struct file *file, unsigned long addr, unsigned long len) { @@ -45,6 +48,7 @@ static inline void arch_clear_hugetlb_flags(struct folio *folio) } #define arch_clear_hugetlb_flags arch_clear_hugetlb_flags +#define __HAVE_ARCH_HUGE_PTE_CLEAR static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned long sz) { @@ -54,12 +58,14 @@ static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, set_pte(ptep, __pte(_SEGMENT_ENTRY_EMPTY)); } +#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { return huge_ptep_get_and_clear(vma->vm_mm, address, ptep); } +#define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty) @@ -72,6 +78,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, return changed; } +#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { @@ -79,69 +86,36 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, __set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte)); } -static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot) -{ - return mk_pte(page, pgprot); -} - +#define __HAVE_ARCH_HUGE_PTE_NONE static inline int huge_pte_none(pte_t pte) { return pte_none(pte); } +#define __HAVE_ARCH_HUGE_PTE_NONE_MOSTLY static inline int huge_pte_none_mostly(pte_t pte) { return huge_pte_none(pte); } -static inline int huge_pte_write(pte_t pte) -{ - return pte_write(pte); -} - -static inline int huge_pte_dirty(pte_t pte) -{ - return pte_dirty(pte); -} - -static inline pte_t huge_pte_mkwrite(pte_t pte) -{ - return pte_mkwrite_novma(pte); -} - -static inline pte_t huge_pte_mkdirty(pte_t pte) -{ - return pte_mkdirty(pte); -} - -static inline pte_t huge_pte_wrprotect(pte_t pte) -{ - return pte_wrprotect(pte); -} - -static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) -{ - return pte_modify(pte, newprot); -} - +#define __HAVE_ARCH_HUGE_PTE_MKUFFD_WP static inline pte_t huge_pte_mkuffd_wp(pte_t pte) { return pte; } +#define __HAVE_ARCH_HUGE_PTE_CLEAR_UFFD_WP static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) { return pte; } +#define __HAVE_ARCH_HUGE_PTE_UFFD_WP static inline int huge_pte_uffd_wp(pte_t pte) { return 0; } -static inline bool gigantic_page_runtime_supported(void) -{ - return true; -} +#include #endif /* _ASM_S390_HUGETLB_H */ diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 594d5905f615..67bbdafcfc22 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -42,20 +42,26 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) return pte_modify(pte, newprot); } +#ifndef __HAVE_ARCH_HUGE_PTE_MKUFFD_WP static inline pte_t huge_pte_mkuffd_wp(pte_t pte) { return huge_pte_wrprotect(pte_mkuffd_wp(pte)); } +#endif +#ifndef __HAVE_ARCH_HUGE_PTE_CLEAR_UFFD_WP static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) { return pte_clear_uffd_wp(pte); } +#endif +#ifndef __HAVE_ARCH_HUGE_PTE_UFFD_WP static inline int huge_pte_uffd_wp(pte_t pte) { return pte_uffd_wp(pte); } +#endif #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, @@ -106,10 +112,12 @@ static inline int huge_pte_none(pte_t pte) #endif /* Please refer to comments above pte_none_mostly() for the usage */ +#ifndef __HAVE_ARCH_HUGE_PTE_NONE_MOSTLY static inline int huge_pte_none_mostly(pte_t pte) { return huge_pte_none(pte) || is_pte_marker(pte); } +#endif #ifndef __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE static inline int prepare_hugepage_range(struct file *file, From patchwork Mon Oct 7 07:50:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13824295 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 42F55CFB440 for ; Mon, 7 Oct 2024 07:51:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E27B76B00FF; Mon, 7 Oct 2024 03:51:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DABE96B0101; Mon, 7 Oct 2024 03:51:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB10D6B0102; Mon, 7 Oct 2024 03:51:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 91DB16B00FF for ; Mon, 7 Oct 2024 03:51:01 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5005F41587 for ; Mon, 7 Oct 2024 07:51:01 +0000 (UTC) X-FDA: 82646035122.02.7ACDED1 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf16.hostedemail.com (Postfix) with ESMTP id 2F842180006 for ; Mon, 7 Oct 2024 07:50:58 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; 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=1728287282; 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; bh=kq2RdgQb0mKyeaOHfiwxxd77dxocKDNXtjk1ZFwjev0=; b=BkUMSHJL/Y15AlCJlUep9JrS6GU37NzwymNtvBfDzJVHEzkvzJYXAiLt5AlIKphdAFdADI J90YJlGoeyIpCxWz8b9990jFxOgSSJQt40uAqh3uHT25GqjssNnaLbQhRPB/44vx5BDkM1 9dN4NBFsmhTBDX5AF/o5uJ9+XwNpAT4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; 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=1728287282; a=rsa-sha256; cv=none; b=JQ1/hIaMIxHfYxw31DM8so7KoH3z0JvTF9rV8gNnmPhjLEVPNUR2TcY5fTOqs6RNWQOgmu 2M1XgnMC0YztgkklNrMGqaZ1wz3K+Gy87TBlzVv4Gxibv8DYYAV09ag29UJAASEdddJ5QW 0kFt1/kuBY/hiMA08pndlRvZOoCKQYI= 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 DF4751FD26; Mon, 7 Oct 2024 07:50:57 +0000 (UTC) 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 3FF8C132BD; Mon, 7 Oct 2024 07:50:57 +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 cObODOGSA2d6cQAAD6G6ig (envelope-from ); Mon, 07 Oct 2024 07:50:57 +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 9/9] mm: Consolidate common checks in hugetlb_get_unmapped_area Date: Mon, 7 Oct 2024 09:50:37 +0200 Message-ID: <20241007075037.267650-10-osalvador@suse.de> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241007075037.267650-1-osalvador@suse.de> References: <20241007075037.267650-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2F842180006 X-Stat-Signature: nj53kqfaufu1zap6ir8har5m9wesq5m1 X-Rspam-User: X-HE-Tag: 1728287458-965155 X-HE-Meta: U2FsdGVkX185qVj0Lhd3exX7uEZRG5FPgEjzI+YYWce/30U26wxWboCpxQw3MqRwldpUhGFqSJm0cKpbuZx3YF0/x7v/FY+1XqqNssvNjOv4Q4MYfFBopSpXCNvWMTCyXJZt0lLB6lHqhCRRMobcb9NC7EisebYx7zN0VnLRTgUp+CiUYIN0e/OOUcaQZSaIUgSHaAF3Ov5q2Y53oilgd/8LJ5+EuGmQ1rMmnxU7YnHCvG3PmKcWzbtPW/9ccDGqV3fPvcUisT8INSfFUN8GekvBabvHikWU2lERM3og9hWLq1MW+tu1GhftUjNywfDP8mamqKeKnPAw9MoaV/IuVnArMpEev9t8k/bbnJHGl63jziKRsdPg3y4Q3G4+03kUb0dbBe9TwX2yj7byBIKtpYhXBrk2/NF07AwSlTn+3L8DV/WS6M0zy7/OLabLaCKLmFzMsjpG/rCcruC20ZHnBeufsPKWvlxTeUvSVAntJ2bjfud3rdO2TmDfGruTQu4U5kshoY6aVdDuMi5p04GD71FDZTXQLPwPLHUZ0p8Lupu36P7N0Wfypx1AP6fJVKrf8DedZ++HXZi4CJOgcQCsXOi/uueNYBbzO061awJVKSXtP+1hTfQvFqV8tbYZ1L4RIaGjYbvX9KYXRBfRMOj2dSOKqURCvWMHqMrMb/4CRBdMwH6VITykyeA9qK9+//FcQEq+6aMHC8D/Ctq0XqHn3n4u67zXRfExhBUPq82HJ7rEdw1zEoITENtLP7Z6Q1vRXF/c6aYXt5wb35H5gJqDDyKocKHWehaKqSK5S4xeETD3sC+6A16hjHIdSwULcMU/zHY7b3iMF76u5ulu8je5ctch+r4C/mzt/vgBSTbDqY5ajEuf04jiRF2LPxK4q71MDhZTRa48yyiaXMxof51bxSVCDmxEJPp3sFuWXbOAVJQhvRj44Re5gpVrWKVvqH1J0khlUSOtl6T1+JPkFxl DO7zjsD/ axcXjK737HMDDYGtuv2NqTQG3ulfhmAeD4IyqTIsONpaJg+AbLoEMT4sOCCWwXQFrJnxTpWUw5s/+ZS8fNZzKXlWvMuTrbzJ14kpiW1MKOP6X5EYOGwuAmNOr8yWiepkHJjWu92y66x+k/pRdx2NQmXny3rg9OZD8dEzlzvrUY5b/4GY= 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: prepare_hugepage_range() performs almost the same checks for all architectures that define it, with the exception of mips and loongarch that also check for overflows. The rest checks for the addr and len to be properly aligned, so we can move that to hugetlb_get_unmapped_area() and get rid of a fair amount of duplicated code. Signed-off-by: Oscar Salvador --- arch/loongarch/include/asm/hugetlb.h | 5 ----- arch/mips/include/asm/hugetlb.h | 4 ---- arch/parisc/include/asm/hugetlb.h | 15 --------------- arch/s390/include/asm/hugetlb.h | 17 ----------------- arch/sh/include/asm/hugetlb.h | 15 --------------- fs/hugetlbfs/inode.c | 8 ++++++-- include/asm-generic/hugetlb.h | 7 ------- 7 files changed, 6 insertions(+), 65 deletions(-) diff --git a/arch/loongarch/include/asm/hugetlb.h b/arch/loongarch/include/asm/hugetlb.h index 5da32c00d483..b837c65a4894 100644 --- a/arch/loongarch/include/asm/hugetlb.h +++ b/arch/loongarch/include/asm/hugetlb.h @@ -16,12 +16,7 @@ static inline int prepare_hugepage_range(struct file *file, unsigned long len) { unsigned long task_size = STACK_TOP; - struct hstate *h = hstate_file(file); - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (addr & ~huge_page_mask(h)) - return -EINVAL; if (len > task_size) return -ENOMEM; if (task_size - len < addr) diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h index fd69c8808554..6a63d82a8ab3 100644 --- a/arch/mips/include/asm/hugetlb.h +++ b/arch/mips/include/asm/hugetlb.h @@ -19,10 +19,6 @@ static inline int prepare_hugepage_range(struct file *file, unsigned long task_size = STACK_TOP; struct hstate *h = hstate_file(file); - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (addr & ~huge_page_mask(h)) - return -EINVAL; if (len > task_size) return -ENOMEM; if (task_size - len < addr) diff --git a/arch/parisc/include/asm/hugetlb.h b/arch/parisc/include/asm/hugetlb.h index 72daacc472a0..5b3a5429f71b 100644 --- a/arch/parisc/include/asm/hugetlb.h +++ b/arch/parisc/include/asm/hugetlb.h @@ -12,21 +12,6 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); -/* - * If the arch doesn't supply something else, assume that hugepage - * size aligned regions are ok without further preparation. - */ -#define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE -static inline int prepare_hugepage_range(struct file *file, - unsigned long addr, unsigned long len) -{ - if (len & ~HPAGE_MASK) - return -EINVAL; - if (addr & ~HPAGE_MASK) - return -EINVAL; - return 0; -} - #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index 37e80a32623a..6f815d4ba0ca 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -25,23 +25,6 @@ extern pte_t huge_ptep_get(struct mm_struct *mm, unsigned long addr, pte_t *ptep extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); -/* - * If the arch doesn't supply something else, assume that hugepage - * size aligned regions are ok without further preparation. - */ -#define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE -static inline int prepare_hugepage_range(struct file *file, - unsigned long addr, unsigned long len) -{ - struct hstate *h = hstate_file(file); - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (addr & ~huge_page_mask(h)) - return -EINVAL; - return 0; -} - static inline void arch_clear_hugetlb_flags(struct folio *folio) { clear_bit(PG_arch_1, &folio->flags); diff --git a/arch/sh/include/asm/hugetlb.h b/arch/sh/include/asm/hugetlb.h index 75028bd568ba..4a92e6e4d627 100644 --- a/arch/sh/include/asm/hugetlb.h +++ b/arch/sh/include/asm/hugetlb.h @@ -5,21 +5,6 @@ #include #include -/* - * If the arch doesn't supply something else, assume that hugepage - * size aligned regions are ok without further preparation. - */ -#define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE -static inline int prepare_hugepage_range(struct file *file, - unsigned long addr, unsigned long len) -{ - if (len & ~HPAGE_MASK) - return -EINVAL; - if (addr & ~HPAGE_MASK) - return -EINVAL; - return 0; -} - #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 935c0ed3aa1e..c6191a6118b8 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -181,8 +181,12 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, if (len & ~huge_page_mask(h)) return -EINVAL; - if ((flags & MAP_FIXED) && prepare_hugepage_range(file, addr, len)) - return -EINVAL; + if (flags & MAP_FIXED) { + if (addr & ~huge_page_mask(h)) + return -EINVAL; + if (prepare_hugepage_range(file, addr, len)) + return -EINVAL; + } if (addr) addr0 = ALIGN(addr, huge_page_size(h)); diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 67bbdafcfc22..f42133dae68e 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -123,13 +123,6 @@ static inline int huge_pte_none_mostly(pte_t pte) static inline int prepare_hugepage_range(struct file *file, unsigned long addr, unsigned long len) { - struct hstate *h = hstate_file(file); - - if (len & ~huge_page_mask(h)) - return -EINVAL; - if (addr & ~huge_page_mask(h)) - return -EINVAL; - return 0; } #endif