Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp538917lql; Mon, 11 Mar 2024 09:47:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9VyuMCTzz0uydX4X61O/IpqqoRti6gAxDR0FhMteUsVIBpN9mFpVtNyOsWM3vQ7LOQOdZVpWtKZJypQpx7gmgrm9vl/bP6jW+ApScRw== X-Google-Smtp-Source: AGHT+IGn3iiL55POWKzQmjSttFNk34WWGUg8v19EcfVjcIAjLiaXxG959XcNKzXWVgLLTk/dEFoj X-Received: by 2002:a9d:6d08:0:b0:6e2:dec9:2b8a with SMTP id o8-20020a9d6d08000000b006e2dec92b8amr7901091otp.32.1710175628765; Mon, 11 Mar 2024 09:47:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710175628; cv=pass; d=google.com; s=arc-20160816; b=xEE32vL3e3jJ5HH6CyTChUOrr0JcbLrwHLHTffU0Gj5cEpqF4DB7NowtrCj4rNIBYF IuP0uf/u5QIUm5P3t4s1Bn7I5vn931ODYiMG7q+QQFLTbLWdXxpfjgsl4PBQ3QeagAwa 5/pBi3+I4Il0oko7A4K9v/E0dkirb9fISzDwM/SscqY5xf8WXgXwFUBpd/47KdDUYAZh Bpk5CTS5tKi2niyfbEeCjRQtqERmboDmM6WMI9rxJ/W3oROsPpdRa75W9UhCqxCL9GhN mr43WXsiQBHbYdaY8/5kXqs5KH7tsb0PW0WuVAKzXFRGorgSYqGdGP1o+kh9wx81eonm XrEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=uRKHBCRgEDsAkh8Uu5g0LvaNrGLtTcS4Fv1I3hMOqvE=; fh=kQiLOTmmTYT/RnYbETsrCCUkzAGxYfMbAVQHF5Hzuqo=; b=mudWyeIwik3uhem2hu7XwmqlLv9+QXALPUGtqc+0x1zONHy0DyG7T7mECRoSuSFOTV oDsPSv7FxBdyrMBDwEdJKchUGGZ8jGFM5+V3G4fzvaw5TUFaV3se2fwl0ry68d1U9OJl C07gD8G6IZ+heLfxiglTzteAguh6IuSiReGLFOGJ43W/n3WkeeAK5QijVO28j/7/7ybm 1wtWu5d6+txjOmjISgFz52oQIL0abMqXy7BEHOfFew0djjC7eXUPtioQxM/EMQjDNaj3 2hqxFS0YRCKfccq/1218T2HjlptpF3BlDBPO2p9RvwMnBkS8/fT6VVHK9SoyJgm1erWm m/Kg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=NdFUqRgw; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-99258-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99258-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z2-20020a656102000000b005ce7efd2eb5si5102051pgu.266.2024.03.11.09.47.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99258-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=NdFUqRgw; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-99258-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99258-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 36B63B20E52 for ; Mon, 11 Mar 2024 16:47:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D90654AEDA; Mon, 11 Mar 2024 16:46:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b="NdFUqRgw" Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 883D547F6B for ; Mon, 11 Mar 2024 16:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175608; cv=none; b=fQmB/FI16LpToZ7muUDS6eEt3uVYpEh6XNhedV3YaP48NkGBXdENXYgy149NQrD0n9Fk7DUx1Wmpur3R4sQWE3Io+aIppEot9kQDgD6KEHu3I357qiFHliQ61gvfSdBceTf/mVOJwX1ib3XSUy7bK0zCNwGppT1etlRtyfUNmEg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175608; c=relaxed/simple; bh=rNSw66o+XpxAmDCLp/4Y0L0j3NJA6sLvc+VkxIH0y8g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=egiqYDUeVTxKgLghmoEQRABkGhepRAbEZsJJcw0hhJVQHjWbdb7mQMkWpwGnve7UJd9OOPMT+u1++Ik569X1cg2cWUF8CGRDHqF6r4+Me+scsTD+zKBxBTTQuMulUVkzVFafOT4zGhHdtIMBiRKkPtRbdlcP0rLxmOekxea6z60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b=NdFUqRgw; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-22181888b88so3895624fac.1 for ; Mon, 11 Mar 2024 09:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1710175605; x=1710780405; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uRKHBCRgEDsAkh8Uu5g0LvaNrGLtTcS4Fv1I3hMOqvE=; b=NdFUqRgwZzPkrAPEBG6Vly8/GajM6oy9t9Cc7v6qZZiUENLwc8xDKDA40eIsvDxLke KHWZ51VzZZWxK24XkQCe5NhpFSD+7fTad2xoa/+kGX6FyYn+HE1tuSL19AuX0tZ+DB1x wyjb9eaia04Eed/6QvxNFJvZ6K4JueagJ2LXxj0PQ/gspKhR9W+Cs6WvU8bnZXyoCu93 Dwq5RtFypq0rg02fJ60zJACeYkDT2Xi9XjQ/xkE91vQ/dzxCmC+gIR+1ZTY3/8fWbijw OtEASAdUhLVKvMGzcYX6uBadWCGgmHmADgiRQOMQvVFfDiT0Z4LEnfKE7EkKvWE8xvoQ YqOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710175605; x=1710780405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uRKHBCRgEDsAkh8Uu5g0LvaNrGLtTcS4Fv1I3hMOqvE=; b=pC9yqcGs/Rz6XEzSg8iARr1P9IrFZnZP2WzsPaBXZo2vp9FreyZuk7QhzaNj/aS243 cJ+GR67uAvZFe4x9s2T9qqRL378fw4qz4Nq8qITLx0TQd+ImWU3FSHOz9mwWG6aKWXi9 +q6hy5D2nSZoAu5/Ep6Jq1brqbXg6reO4Q6cDevPN9Pm5AqNyCUDn/hGbWklzNVBsh9f OvfMheXhVR/Ac4HTh904YAoULRMR31BdBavrvY2tfAITDcLMTli1eczMbGylyKhr4co5 XXj+xz5C329OLthP+gOjs+RRREChJ6J+waOUiywn3UOnOZFss4RH48BjVaAqF0jmWRS1 iGrg== X-Gm-Message-State: AOJu0Yzc9D20zGJrM/9rM6+lBSClgOxB//2frFdRsu9SnbMBp4catV9u xVdXtRp3u/7mHbUgU6ihs4GWQOeFAwVPrEUWSIalCqHuKqkhNg+XQ5Ge9ScLzvo9AhDfR4prn86 luRA= X-Received: by 2002:a05:6870:4721:b0:21f:4fe:9ee8 with SMTP id b33-20020a056870472100b0021f04fe9ee8mr7898763oaq.4.1710175605333; Mon, 11 Mar 2024 09:46:45 -0700 (PDT) Received: from soleen.c.googlers.com.com (150.254.86.34.bc.googleusercontent.com. [34.86.254.150]) by smtp.gmail.com with ESMTPSA id d27-20020a05620a137b00b00788228fbe05sm2851589qkl.17.2024.03.11.09.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:46:45 -0700 (PDT) From: Pasha Tatashin To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, x86@kernel.org, bp@alien8.de, brauner@kernel.org, bristot@redhat.com, bsegall@google.com, dave.hansen@linux.intel.com, dianders@chromium.org, dietmar.eggemann@arm.com, eric.devolder@oracle.com, hca@linux.ibm.com, hch@infradead.org, hpa@zytor.com, jacob.jun.pan@linux.intel.com, jgg@ziepe.ca, jpoimboe@kernel.org, jroedel@suse.de, juri.lelli@redhat.com, kent.overstreet@linux.dev, kinseyho@google.com, kirill.shutemov@linux.intel.com, lstoakes@gmail.com, luto@kernel.org, mgorman@suse.de, mic@digikod.net, michael.christie@oracle.com, mingo@redhat.com, mjguzik@gmail.com, mst@redhat.com, npiggin@gmail.com, peterz@infradead.org, pmladek@suse.com, rick.p.edgecombe@intel.com, rostedt@goodmis.org, surenb@google.com, tglx@linutronix.de, urezki@gmail.com, vincent.guittot@linaro.org, vschneid@redhat.com, pasha.tatashin@soleen.com Subject: [RFC 02/14] fork: Clean-up ifdef logic around stack allocation Date: Mon, 11 Mar 2024 16:46:26 +0000 Message-ID: <20240311164638.2015063-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240311164638.2015063-1-pasha.tatashin@soleen.com> References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit There is unneeded OR in the ifdef functions that are used to allocate and free kernel stacks based on direct map or vmap. Adding dynamic stack support would complicate this logic even further. Therefore, clean up by Changing the order so OR is no longer needed. Signed-off-by: Pasha Tatashin --- kernel/fork.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 0d944e92a43f..32600bf2422a 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -179,13 +179,7 @@ static inline void free_task_struct(struct task_struct *tsk) kmem_cache_free(task_struct_cachep, tsk); } -/* - * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a - * kmemcache based allocator. - */ -# if THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) - -# ifdef CONFIG_VMAP_STACK +#ifdef CONFIG_VMAP_STACK /* * vmalloc() is a bit slow, and calling vfree() enough times will force a TLB * flush. Try to minimize the number of calls by caching stacks. @@ -337,7 +331,13 @@ static void free_thread_stack(struct task_struct *tsk) tsk->stack_vm_area = NULL; } -# else /* !CONFIG_VMAP_STACK */ +#else /* !CONFIG_VMAP_STACK */ + +/* + * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a + * kmemcache based allocator. + */ +#if THREAD_SIZE >= PAGE_SIZE static void thread_stack_free_rcu(struct rcu_head *rh) { @@ -369,8 +369,7 @@ static void free_thread_stack(struct task_struct *tsk) tsk->stack = NULL; } -# endif /* CONFIG_VMAP_STACK */ -# else /* !(THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK)) */ +#else /* !(THREAD_SIZE >= PAGE_SIZE) */ static struct kmem_cache *thread_stack_cache; @@ -409,7 +408,8 @@ void thread_stack_cache_init(void) BUG_ON(thread_stack_cache == NULL); } -# endif /* THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK) */ +#endif /* THREAD_SIZE >= PAGE_SIZE */ +#endif /* CONFIG_VMAP_STACK */ /* SLAB cache for signal_struct structures (tsk->signal) */ static struct kmem_cache *signal_cachep; -- 2.44.0.278.ge034bb2e1d-goog