From patchwork Tue Apr 2 00:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13613169 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 E0B27CD128A for ; Tue, 2 Apr 2024 00:15:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A985D6B007B; Mon, 1 Apr 2024 20:15:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1FF06B0098; Mon, 1 Apr 2024 20:15:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89A2F6B009B; Mon, 1 Apr 2024 20:15:15 -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 6756A6B007B for ; Mon, 1 Apr 2024 20:15:15 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2FC571C07DD for ; Tue, 2 Apr 2024 00:15:15 +0000 (UTC) X-FDA: 81962672190.16.621F38F Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf12.hostedemail.com (Postfix) with ESMTP id 58A8540003 for ; Tue, 2 Apr 2024 00:15:13 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kpwYDVpi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of 3D04LZgMKCBA5ssw44w1u.s421y3AD-220Bqs0.47w@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3D04LZgMKCBA5ssw44w1u.s421y3AD-220Bqs0.47w@flex--pcc.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712016913; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=ObPEVpHNGOD9pdNTP5+iZiD9N6DasBI0eYYI9ayJs3Y=; b=g0Bor5pDP2WiNOBh3BClKngjXWRLxa2TN2mJI/UkznFJFcpBI+uyU7sW/jrjqIzae1yQ1j 28ie+AhhtsU98awd/pGdX4oPbDZLmoA4ZIo4nevsyBmHM+ZG2yaDFrcszO2b0ICwIo+787 VWyISIoOuPTgch8MDsNM59oh88DvlfY= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kpwYDVpi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of 3D04LZgMKCBA5ssw44w1u.s421y3AD-220Bqs0.47w@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3D04LZgMKCBA5ssw44w1u.s421y3AD-220Bqs0.47w@flex--pcc.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712016913; a=rsa-sha256; cv=none; b=iVzu5OmaXc4VS/rsHaLz1bXmcVhQDif50I7QQLJ+89ldH8tQRlZEa82nX7itXq1rUm5hKA A5cd0VJJFdYsT6iXTWQAjKhxW9lbSI9QU/pFNT19FesUEgVJCGtaXQP2r3I2e3VPvA+mfW yMmOkT+tYEjMp/V80XgiahkXGGXyo6M= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dd8e82dd47eso6125605276.2 for ; Mon, 01 Apr 2024 17:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712016912; x=1712621712; darn=kvack.org; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=ObPEVpHNGOD9pdNTP5+iZiD9N6DasBI0eYYI9ayJs3Y=; b=kpwYDVpiQExigcXtfe2OQLcTLv8sIsp3os6lO1OZlHc8aVHMXMDRltBk5X5GrR2CDa 1bRPvdLpWRpYhhTaFKMQIVeT9aZXio2mU+a2t+okotUhUuOWiP+W2Ic0NOZj4N+HfCqa fOAbe0r35l+dnQDgCjQrvhtZGOe7xw1hmeiO1+sZvrL2g62OqSodHuN8Ib4xwMHIzuD9 8a4gCkXgoQ+rzR0wdXzazbbelBhUc00bUvhbjuU0k8q58Z2DOX59oW/K7Z+wecI/htZw glvPZhPlPcG5ndIgIHW24xNMPL4BX8yzn5yhYjwSi7OMMB241I3stRg0E8iqS4rYR3Aa HmEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712016912; x=1712621712; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ObPEVpHNGOD9pdNTP5+iZiD9N6DasBI0eYYI9ayJs3Y=; b=mEErfgWxdMm73OG+Q536TNfOcz4SJtrsUdIlIlheV8dQsGYa44v0bmUesBT/rAOx+G r7qMMqvBDan7jGx/j+uCwsd2cKvcfXromekiBxYFAsB21sATQOt1Xih39+uZhhr1iu36 pqJm3Ckzr1/8C3RkKaHdcKoJLzWTnObdMdHH/bpKwEBlF+obmFVR5/Cc5D8UGWDrGf2Y kmLCc2lbtqleSSRZZRPCCoIoLwW2zFM2LkRr6h1ptwXPgDGaCQ2tohS1jw7ZDe6UK9lr 0trI+CWVBzHY5N8Ns4x6B3bfNIHCRAfa2r/4qelOwXKZIhbqaLeWkvBqqBjTXCXalcqX SWag== X-Forwarded-Encrypted: i=1; AJvYcCWM/WsnFOCwEIM2orSH8LHy5XT41BY86VmFGCxyx0hkSY28iWM/BLXOVwL6Y6pVIpmjAaoqPlOnZduNc5OlMgPDYqE= X-Gm-Message-State: AOJu0Ywrvb2vjxO7kJ5Ztn88j7fhxBXSAo/HJ4MUhW/aq4OJvzYviT9U gB3/t2xHCofkW2d8kKncuZSzOfI3jBXdaEwvICAmckqQK01qyCd0KkdD/KgmavOjDw== X-Google-Smtp-Source: AGHT+IHcf+ixx+OL89EP7m/1Ir1689eKnCKk7owZQ2kqfE8f5cmiNwb1vTS8CEnpi1GrK1srUOQBsLY= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:187d:146c:8be:181e]) (user=pcc job=sendgmr) by 2002:a05:6902:1021:b0:dc7:82ba:ba6e with SMTP id x1-20020a056902102100b00dc782baba6emr775831ybt.7.1712016911935; Mon, 01 Apr 2024 17:15:11 -0700 (PDT) Date: Mon, 1 Apr 2024 17:14:58 -0700 Message-Id: <20240402001500.53533-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Subject: [PATCH] stackdepot: Rename pool_index to pool_index_plus_1 From: Peter Collingbourne To: Andrey Konovalov , Oscar Salvador Cc: Peter Collingbourne , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Marco Elver , Alexander Potapenko , Omar Sandoval X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 58A8540003 X-Stat-Signature: t89dscasj3n7u15a4zkkyfssu8p8zs17 X-HE-Tag: 1712016913-953205 X-HE-Meta: U2FsdGVkX19CV9ywb+R6+iwAqz/+tVarGewXT+9ayvfoMx5Mwwq1PjBzwFj8eVMKO3BBoq1XrImGdtixEL8NciPxzP59+iz00CWvHtfkchQp+LZFVIXXLWOuSJuoX0B+f66FLUieMEtQMVwZPDk4RleZWMALP0UXysjpWtzM1HKhPJAZ5fq6Y6GBxB927ww29yvm4/XZacf2lAsioXif+yfbrknfWNlFYHT90+o60znsCT42VFg7/cmWCZn0KxuS7Xjf0lz3VwQIjieThQ1nzq2NeF0nZo4/FA9mLlos4mHB+Jie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kqJ1KRXrtp4uBEQVNaQI8HQsSnJrtyfjgCpdG9HYjhwMgZfaXsjePFG6CjlLhyWC3zk3JHBv+CB1VytqYZfQ0y+QBuReVpvObzlg+Ro3vfgON5v3C5T72JHtsf3O2gdq/nzbgkvfy3vM4pdoh5VIv9OK0CnQl1QH/rHU+Yl0Kothcg+muCnnnLWeVyvcrBYtI4Tgxqc+z4qfF8zdHKVgLcuDs9sDbcyCmQPCZsJjX+8qTg9wFgygwMAIKh0U/3T3pjdW+/RWtTeqpDLeVhPtpXiVwrDgtS9K3Z7xJ 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: Commit 3ee34eabac2a ("lib/stackdepot: fix first entry having a 0-handle") changed the meaning of the pool_index field to mean "the pool index plus 1". This made the code accessing this field less self-documenting, as well as causing debuggers such as drgn to not be able to easily remain compatible with both old and new kernels, because they typically do that by testing for presence of the new field. Because stackdepot is a debugging tool, we should make sure that it is debugger friendly. Therefore, give the field a different name to improve readability as well as enabling debugger backwards compatibility. Signed-off-by: Peter Collingbourne Link: https://linux-review.googlesource.com/id/Ib3e70c36c1d230dd0a118dc22649b33e768b9f88 Acked-by: Vlastimil Babka Reviewed-by: Alexander Potapenko Acked-by: Marco Elver Acked-by: Oscar Salvador --- Although this technically isn't a bug fix in the kernel, I would appreciate if this could be picked up for 6.9 to avoid temporarily introducing a silent regression in drgn (loud regressions are fine). include/linux/stackdepot.h | 7 +++---- lib/stackdepot.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 3c6caa5abc7c..e9ec32fb97d4 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -44,10 +44,9 @@ typedef u32 depot_stack_handle_t; union handle_parts { depot_stack_handle_t handle; struct { - /* pool_index is offset by 1 */ - u32 pool_index : DEPOT_POOL_INDEX_BITS; - u32 offset : DEPOT_OFFSET_BITS; - u32 extra : STACK_DEPOT_EXTRA_BITS; + u32 pool_index_plus_1 : DEPOT_POOL_INDEX_BITS; + u32 offset : DEPOT_OFFSET_BITS; + u32 extra : STACK_DEPOT_EXTRA_BITS; }; }; diff --git a/lib/stackdepot.c b/lib/stackdepot.c index af6cc19a2003..68c97387aa54 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -330,7 +330,7 @@ static struct stack_record *depot_pop_free_pool(void **prealloc, size_t size) stack = current_pool + pool_offset; /* Pre-initialize handle once. */ - stack->handle.pool_index = pool_index + 1; + stack->handle.pool_index_plus_1 = pool_index + 1; stack->handle.offset = pool_offset >> DEPOT_STACK_ALIGN; stack->handle.extra = 0; INIT_LIST_HEAD(&stack->hash_list); @@ -441,7 +441,7 @@ static struct stack_record *depot_fetch_stack(depot_stack_handle_t handle) const int pools_num_cached = READ_ONCE(pools_num); union handle_parts parts = { .handle = handle }; void *pool; - u32 pool_index = parts.pool_index - 1; + u32 pool_index = parts.pool_index_plus_1 - 1; size_t offset = parts.offset << DEPOT_STACK_ALIGN; struct stack_record *stack;