Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp539104lql; Mon, 11 Mar 2024 09:47:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZZwHhHjaPclrbG1OsadZsvGNipdn74FSbIP40x0TlYAZdphZbol2868dOpA9Rh8Uzg+d7hMF+zLqTHcGrrdMjd4INnIxrhV47b9Fg0A== X-Google-Smtp-Source: AGHT+IECPkEm+8FYv0O8o6MjD0Cm3zaq02D0bKm7f1MtFqj32Wae5XWrIJYMoxUtX1R7vNC3jyjc X-Received: by 2002:a17:907:d389:b0:a45:92c4:7892 with SMTP id vh9-20020a170907d38900b00a4592c47892mr5596755ejc.56.1710175642902; Mon, 11 Mar 2024 09:47:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710175642; cv=pass; d=google.com; s=arc-20160816; b=00TM6UVYtDYCPrMYPupDCrZQQov+ovMbQC/x5QsbKQSJwjSqzmuyKyn5SSbVZVvvlB e932AzOpSm4OI1QcJkpv4j5/NF6kH4I/Lw/XEWUaTr54az69bpB7/f5wj1MiysSDwPlz qhx+vS5oI+fr2xVZFO1nBXt2wKLRuREG7dec4Wioso185qbCFW43tsPgYGcQgg6SITQW zSZWpYKDn6yHIbOiKaFmP3p2EMVeATh/mUXBX0RX1dNTV6P0GAxgCgRmdDMqwq9zTSSN SzPfMGHJ7s7cUCHu52WgZcQg5PXjH3sPv50Cv0cerWSQgmmJEp1hoVrX4/Mu+71bYnXm vFNg== 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=HoufURnUHz+cr/acEvSc8ejQyNfvHWk1Ds3/A5XAtBc=; fh=kQiLOTmmTYT/RnYbETsrCCUkzAGxYfMbAVQHF5Hzuqo=; b=O5ZP5Xb1M4hFSulcwk23JBVqdbvRPYwzEsoIg6YBX4oymOGBGoouI+D+BAe3mfo9dT rION1OyM8AYuHVJOqbsEE8OcQecNQIoQN1sd3Eus+GAjGDR8/HsaY8Zjg15SCpyrzDm5 1QomQhHCndGvs3WxjCZx3gHfZYtK6yZNeMdyBhO4Dp/xBeQGrfM/1A/RtjtBhu4UNCur eLwenOld/O+oIOu+X2KMK2L9RMLgebbuFsZvg6NVvIQR7OK0AjKmhN+hRVcf+ijTe+xH Z+bHFPrQtexEso6C4k4sziXY8XNx699BREyV/vBcru994scoSC0pvGm1ZSX23MsCtVpF 0GBg==; 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=mQTT3A9v; 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-99260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99260-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qw39-20020a1709066a2700b00a44b9329951si2584629ejc.627.2024.03.11.09.47.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 09:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=mQTT3A9v; 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-99260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99260-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2EF6B1F222D2 for ; Mon, 11 Mar 2024 16:47:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33CFC4F205; Mon, 11 Mar 2024 16:46:50 +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="mQTT3A9v" Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (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 77229482C8 for ; Mon, 11 Mar 2024 16:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175609; cv=none; b=jxSn2S4elh1VQO+uCOB8vgPGvj4lP8R/j7qF0fcNwZGneOjSGOjvWyFMC6XlzM1IdG+ynqRBdJSMrtnajBdrkQTk/1RFH2Cb1nzodapsHFrbMMJzTSTmi6G9q8yi0cSPSl/5hzhOKUIcAUTW01Q0GU2pwS3F91gwVhWH5EyHKT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710175609; c=relaxed/simple; bh=tEvVrQdda52ZeoTZCZGpLyifsvZ4B54Au/IQTs3CyBY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ns6TQ6VKLgGQMZXreh3KxYS6XESyfsN7IQ2Jkz6cEZGNqdmKkwsCoo3bPNIsNA3cce4cWjuXeyGWjPp9kI7+FIgomeTIF9bCAtzEvcb0C+d8DPrT+EC2AZpIgx9PvKEEsADmVF8UmTo6xQ9XtCpk1dv2dRLNybeSPIHeZNIa9dQ= 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=mQTT3A9v; arc=none smtp.client-ip=209.85.222.179 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-qk1-f179.google.com with SMTP id af79cd13be357-7882e94d408so382722985a.0 for ; Mon, 11 Mar 2024 09:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1710175606; x=1710780406; 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=HoufURnUHz+cr/acEvSc8ejQyNfvHWk1Ds3/A5XAtBc=; b=mQTT3A9vqwHQNYTdHWJygzw8tcaJfBI7IIbzYESS5ds1wk3CkSvRc3G8gYZ9Yx4xd1 WuLOFK3uodx7DUGJHqwoWZUn1yu5VNDonE6bIJWoqLcmoLHzFXYZp/86Z7kgxPetBGcV XieCbZKVad8qPUsUym6gVTPlcaebw15P/vhb63W66HG6KTxZPcKiCGsSAZ6hDQSByy/D Dlb/GG1dLT3OZZEM6p5ox/BMfIPyRU51Nd/FEa0uDZIEEv9Af1xPQzjuPtmlwhfbJRqV iOF9/0/J/8AmFNXlXSnmVl58R1RUOwRpta/wAkxbP/VbLlVlFn2KBmNuu1VWFNauAWD3 gfew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710175606; x=1710780406; 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=HoufURnUHz+cr/acEvSc8ejQyNfvHWk1Ds3/A5XAtBc=; b=TisOJKYWBzP47zQWt6T5wEXj2uTE3sO+yudfuv4yR88anHIySym1jqr8aNu4EuU74H LouTTF3dMta3/oN0Tt2eFovZZ0BjdByjy/yR73AQAEiXbf68EBZGPYJD0LJQq8lR+cKg HzINZ8HRkCwLTs/pH2f/bdY9RsVL4Xl8sXM29K2N5HIQtLQoZLNcGWYAvt8LOtM/Rmtu zi4lPd7WMuNEXjUD9n5m7rw2qi1+/yrxyAdCQ2itNCsovqWj4yA5sBEncIyq/Ej5oh7b i7XUWEtzhqtR8h4udeQKc9046cbAT6JovM7xAtlX6bR0pO8Tvx4KRHUQMpAsMmEZJVUI gElA== X-Gm-Message-State: AOJu0Ywn9U/kqzVZV0qVOOh/cmbS9oNUG8uc34G4F6XOUQSUBnpuD4PF Z6UQkupAlM7aboc+Gl4WtBLp+atvczlZbNMMOwyfRE40bXFkBSbkLUCoJIr0C0tXHh35+N1CzFL 2gag= X-Received: by 2002:a05:620a:13cd:b0:788:3c2b:42e2 with SMTP id g13-20020a05620a13cd00b007883c2b42e2mr8567991qkl.10.1710175606139; Mon, 11 Mar 2024 09:46:46 -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.45 (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 03/14] fork: Clean-up naming of vm_strack/vm_struct variables in vmap stacks code Date: Mon, 11 Mar 2024 16:46:27 +0000 Message-ID: <20240311164638.2015063-4-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 are two data types: "struct vm_struct" and "struct vm_stack" that have the same local variable names: vm_stack, or vm, or s, which makes code confusing to read. Change the code so the naming is consisent: struct vm_struct is always called vm_area struct vm_stack is always called vm_stack Signed-off-by: Pasha Tatashin --- kernel/fork.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 32600bf2422a..60e812825a7a 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -192,12 +192,12 @@ struct vm_stack { struct vm_struct *stack_vm_area; }; -static bool try_release_thread_stack_to_cache(struct vm_struct *vm) +static bool try_release_thread_stack_to_cache(struct vm_struct *vm_area) { unsigned int i; for (i = 0; i < NR_CACHED_STACKS; i++) { - if (this_cpu_cmpxchg(cached_stacks[i], NULL, vm) != NULL) + if (this_cpu_cmpxchg(cached_stacks[i], NULL, vm_area) != NULL) continue; return true; } @@ -207,11 +207,12 @@ static bool try_release_thread_stack_to_cache(struct vm_struct *vm) static void thread_stack_free_rcu(struct rcu_head *rh) { struct vm_stack *vm_stack = container_of(rh, struct vm_stack, rcu); + struct vm_struct *vm_area = vm_stack->stack_vm_area; if (try_release_thread_stack_to_cache(vm_stack->stack_vm_area)) return; - vfree(vm_stack); + vfree(vm_area->addr); } static void thread_stack_delayed_free(struct task_struct *tsk) @@ -228,12 +229,12 @@ static int free_vm_stack_cache(unsigned int cpu) int i; for (i = 0; i < NR_CACHED_STACKS; i++) { - struct vm_struct *vm_stack = cached_vm_stacks[i]; + struct vm_struct *vm_area = cached_vm_stacks[i]; - if (!vm_stack) + if (!vm_area) continue; - vfree(vm_stack->addr); + vfree(vm_area->addr); cached_vm_stacks[i] = NULL; } @@ -263,32 +264,29 @@ static int memcg_charge_kernel_stack(struct vm_struct *vm) static int alloc_thread_stack_node(struct task_struct *tsk, int node) { - struct vm_struct *vm; + struct vm_struct *vm_area; void *stack; int i; for (i = 0; i < NR_CACHED_STACKS; i++) { - struct vm_struct *s; - - s = this_cpu_xchg(cached_stacks[i], NULL); - - if (!s) + vm_area = this_cpu_xchg(cached_stacks[i], NULL); + if (!vm_area) continue; /* Reset stack metadata. */ - kasan_unpoison_range(s->addr, THREAD_SIZE); + kasan_unpoison_range(vm_area->addr, THREAD_SIZE); - stack = kasan_reset_tag(s->addr); + stack = kasan_reset_tag(vm_area->addr); /* Clear stale pointers from reused stack. */ memset(stack, 0, THREAD_SIZE); - if (memcg_charge_kernel_stack(s)) { - vfree(s->addr); + if (memcg_charge_kernel_stack(vm_area)) { + vfree(vm_area->addr); return -ENOMEM; } - tsk->stack_vm_area = s; + tsk->stack_vm_area = vm_area; tsk->stack = stack; return 0; } @@ -306,8 +304,8 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node) if (!stack) return -ENOMEM; - vm = find_vm_area(stack); - if (memcg_charge_kernel_stack(vm)) { + vm_area = find_vm_area(stack); + if (memcg_charge_kernel_stack(vm_area)) { vfree(stack); return -ENOMEM; } @@ -316,7 +314,7 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node) * free_thread_stack() can be called in interrupt context, * so cache the vm_struct. */ - tsk->stack_vm_area = vm; + tsk->stack_vm_area = vm_area; stack = kasan_reset_tag(stack); tsk->stack = stack; return 0; -- 2.44.0.278.ge034bb2e1d-goog