From patchwork Mon Mar 11 16:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13589078 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 A465CC54E58 for ; Mon, 11 Mar 2024 16:46:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1284E6B00CC; Mon, 11 Mar 2024 12:46:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B0E36B00CD; Mon, 11 Mar 2024 12:46:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF4F46B00CE; Mon, 11 Mar 2024 12:46:49 -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 CB2D86B00CC for ; Mon, 11 Mar 2024 12:46:49 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9121D140A6A for ; Mon, 11 Mar 2024 16:46:49 +0000 (UTC) X-FDA: 81885337338.27.1964A32 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by imf07.hostedemail.com (Postfix) with ESMTP id 1FF604001E for ; Mon, 11 Mar 2024 16:46:46 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=AWN84jIn; spf=pass (imf07.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.174 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710175607; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HoufURnUHz+cr/acEvSc8ejQyNfvHWk1Ds3/A5XAtBc=; b=Za9K7wgrJrnJEpJcx8H2Ee7CwvsEI+126OtmyJxaMV7pXswxWR4h6bO3ujnIfxta/ITn6n xAGU9h70wjGbwdb1YZwsjboomSzy3IgTGFoswxxfSPowNiznVlMbpvevu/x1a+k45cibmf jXJiKq9GH5csL5TrbOLWgVEBlMb9cIY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710175607; a=rsa-sha256; cv=none; b=5AxgVctYAca9rBnN2eFc71oQWB5zn/Y6nakJGjnqYdTwTAbUu03eglld/YHAw56S3j21Cy 8N1vx1Zp1JTJkGZWcEZGZkW4r8dnqXUSJ13Za296gPJnDpCTqFa0Yt7Sv10CQcMsvZvNFY vsni4rKdxD5m9/ipqFmSUoZT6N3mqCA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=AWN84jIn; spf=pass (imf07.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.174 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7882e94d408so382722085a.0 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=1710175606; x=1710780406; darn=kvack.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=AWN84jIncySZxiVwwn3sTSgKlKaUOQHYXZfd47h0PxvAN1KxRiD31KKe+WlCNCtfr7 jFmvaCVPVpd0J55nsel2/TzbDpekbrckJEVLCJlhZcXviQmhWNYh+ewXoqGairrFjJHQ qRljche5PHxOdzQj9+jWsdh9VL4TT8s7/rDbDoxq5Ek1zHNN6yU+DqgHLqIk7Vtenf8G 3TFz/CwIy4VzZIFC5ijMAD427MDmR23TiYL0QBbhmrq+369Y5XIicDPwR4srlHUCHLsX 5/zEm2gYx7pMLEHQvPk/LMEwDH0DIMutw96i1V6wwPr+LhuGxTt5kZNMr+J7bcEGS6Z9 Ft3A== 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=IFMqjr0Nqv486BKrYEoL4shLnzDDxLVCPRuuoueOTlvMBFqPYXW4tedtVZR5choO4Z DN0GtJCZBjaYcVz0+CWPBQ/DpoUU0lVqkvIzACJ03R6r+/2AD4DGA8o2XlPLGD8mxMx7 KIqpYqr1EwXiqYpM0yo4wKDUk54Lau6hBde8TeKCxKa3YtpbFKbMHlcnomXgknfHaD+L zjOhCWlXMgBOUb5QBrUacTvYdQr/pC+j/knuFFPBT/bprbFoSiio3N+FEI1sSfm2rR6p KjicusGLTHud95UIpYpanRiXcT+fdT7PiVAlPICs88Mxei22zdkhee6Qg1It1RIoM2e6 JwtA== X-Forwarded-Encrypted: i=1; AJvYcCVovol0qveObtugM33pvthvCcrShhzN7sdheHGgO3gp/jxXK5qQLjiHB5S9xgEBRTeC1oo/gBoqgb9Aft3EthnXKrw= X-Gm-Message-State: AOJu0YxFPg3KNrK+NQKNufAZQPZhOUWwk7GfOBes5U8eFHn/7N55NBD4 JGhPKuxkkGhD922niz13YERov/KyIxuFiIK1TXELRR5/CVHW+Bl/sO81Re2jIKE= X-Google-Smtp-Source: AGHT+IGrhJ6GByyle2ZXj6YELCySZAA2hRd+lCiymK5OoO5mkfddy6eeNIr6RoEdx/yXV9YfoWqMCg== 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> MIME-Version: 1.0 X-Stat-Signature: zb95qscc3mu9w7qszaqs5xbk8qxo9tnt X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1FF604001E X-Rspam-User: X-HE-Tag: 1710175606-477291 X-HE-Meta: U2FsdGVkX1/HKVzQdwGYH16w8gDF2g5qEcKs2eK1PXsveFdy8HNC1c3kjiBcAEjDAxqp+K01HHGDTciLQV+QcSChG5AE0H7kx6wevFDkKH8N8XzMpLQOxrHpiqwWyjQuvC+VCP2l0zR0Q1VvjRWx0TtAHEFzrE3HFkfpmAumq2ta2sIMje0DjmnXTtzeIoaWXzXmybtQiNeGFAGW1njVKgzhP2Ik/1siyvVJoyOyETv6Rul+d4rxdK60sKiMVfmTCz2G2EuoWCvnlsnATo90MsPMcu2UFTrBY3vCJPktNtaw/Z2Z8d7UhoIvSAruvgCNT65tD3yNaY46F2lMxByEWH1fft4VvgLhMgzlzbWJsJDR/kaiEISZm0aKlIAXKX4k4CDx4Uf6VGSd3D8A8Q3LEssor2jZuO4IBh8IZyzesFelsw8dQEP+CGDeFNAga6jdttXUu9biB9cds9GS0DYafzDVRyWKyBNwoAWEqueNcZAk5E5LKLjxQa5Sj4b1bv1vv4sRzXb/KB2le/Z7InT0Q1VCQl/F/XxujLc/m2vsLp7n+f50f9KSRUHCHNrGb/O1/3NZWfokgJ48v5VjbgygsTQrANZ++caI8AP6eQFTO2l6GHzBzWwJWiAZ9cG3boWcdVSTYDWhdFt4QslfB0eEQL9Io/8iVgAyKhD9BeSf6X2HJtGgaiAeMhdD8iu0/FskmZ8TtJMJmSyuaEqGNXctxZieyDXBFCksltdNL/K59m9UdaNPwTSotIyczlfyJWBQHxzv+3c/n8NKPtAi+udbYAPKu5Y2UdMc0YQBDcDXxDjydI47hDZOMGA9GiU0Y7nz9KL5OZe41kp8Y/2TbWzlBG8cIwMxqa7UFSCr4pH/paooqyYt6k497XTfnq1JpyOKtq71mMdq5L1eUN1BsE49SEuXLu2ChpSHEw8OSX8yLCha7vNBKkeGgN1dERot34MeS+8cph2ZRNNCMuV/rF9 AKl4fwV5 gxHg0QxPGtaKw6/P7AI/x52G9wDXt1UJGeLNQDNw5MPj3EJ9/6i20hcUL3p+oslVuiIVA9iu4BbXM2u+S2WezrLK1lj9Nmh3tOIIP0Vg12aaWNSfhPGmBM9yHXCsYdhhiQ+2ClxY7ZkKTlwgS/QtkHET6brzpJzQGsiEAp6KaJ2+ZRS57avUIoNy+3xrRF0qdWEogicVDTm1GS+4MeHEDJWs+JWZBcLOr7puxwow4DF257uDc0wYFTaz72+6wCtMx+xrnJejRRmWwQHCx906MujFfekiGVzcD4Ek9HqNnVJZI22j6GUULcJwVruiv9FrCP03f+pZ73LNCNJR6ld6Txx9CdUcw2cqH24gWlniEtaucVZi+/9EP0y95DNZwjOBl0bjLQzCbhVMUoF6zZiRz1VTerNE3N8sbZuxtAozGS5D9B8pgab7g2tO+YLbUPMry8HpuoYc+N1Xr3VLk4xp1FaE4vXllh4UxZiFMuT7DJvi3COaLlOMcAFW+IupDJBRqA+adSVYdMvvBTF0eISo2Hvp/5JPIysUZ2LSmQcwDkv5uYos= 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: 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;