Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1765354lqz; Mon, 1 Apr 2024 17:24:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbFJc6oJwAPpPrXmNHWSFi9TfCV0xxoEGRKCXiEAJbMhKW6N0eYXt5qtNRvFD/6bjw/tBMNt4aw8SssKW0ODifIn73KFPxDAsdDh8/nw== X-Google-Smtp-Source: AGHT+IGmr6MMSfzQ9wXVHkktMJL5Bi9+Z58SYnB6M2K0c0fgckIRTSl9hxM4Moi808OpRCNC1Odw X-Received: by 2002:a05:6a20:3242:b0:1a1:87a9:5caa with SMTP id hm2-20020a056a20324200b001a187a95caamr7974333pzc.29.1712017456578; Mon, 01 Apr 2024 17:24:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712017456; cv=pass; d=google.com; s=arc-20160816; b=iL+iUepicMlJNgLN4snjOI5oLmzObw/Vz1+6jS6qO+6yXWCoU6OEHCaPwu1glTLLiM tavBjVO/0gC/NZTU7Zx6Sz6sjrRLtr3rwJDG+9U+BZy748+52zyGlFIfntDRxm41tPBX iVv3LtgKgFWStAUV6gUQQmDx1LzWiOxyrBrN+omfKvcYE2ThekTsVx+zBnmNam4KMOQa QQR7fQ3rlNkkMCb/Qiq5RZeS4QaI5x4mGr+Caf6ScROgTEDHppZEF6Qfyiqr+KaF2RiA Ky7jtXSpuv/mNv9iO77sIEp2qPAtwionUa6KkKIn9u+nbYJLgwgpp0QyAf2j4X43aPOB ZRnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date:dkim-signature; bh=ObPEVpHNGOD9pdNTP5+iZiD9N6DasBI0eYYI9ayJs3Y=; fh=4EcsG6uKXbx+8sF5eBEv35txILZ/8KJWtuHHgtBdMrk=; b=PTAulm28jZOFSksMIRTOsQ5bRBgju9DrWI/SAvcal00ZOQaNuEHkcJbXHSKfYPk9MC m0OpP9Y8HYFk31OpmEPJJ6OIT73XLu2qUxbkcwxx0O2uxFBs2e/yJsR6Cp0wfk0wJqK5 O8kBqPYeSSdIetylo0oPGbSj/4/aGi8TgimVfn94SdVUPnR08TplzrELNT6iYuFX4cvI 0vzTnRaGn4ibSOKUC/jrCyqAT5T53FAZcOZTJNt8I8jsd6CWKfK+bsbFFfrDfBL5L0Pp +lhV3EZ6+r7xbBQ5YIKsgyczYeU4mj8DDw/7e7Cjy1y+ROp+q0LZQAhyDfpzI3NQE2Dy H+gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vkdeewZ3; arc=pass (i=1 spf=pass spfdomain=flex--pcc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-127230-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127230-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l9-20020a170903120900b001dcd642ab02si10397608plh.75.2024.04.01.17.24.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 17:24:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127230-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vkdeewZ3; arc=pass (i=1 spf=pass spfdomain=flex--pcc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-127230-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127230-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DAFFC285AC1 for ; Tue, 2 Apr 2024 00:17:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B507D16419; Tue, 2 Apr 2024 00:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vkdeewZ3" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 59DEC14A9F for ; Tue, 2 Apr 2024 00:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712016914; cv=none; b=V3fRYiArXC7/LWMJ3q6BrumCPcnKDMxLHHAV0eg9xfvA5KYRuxf+eE0Tmi0+j0eHP29IxEJQza7czfzTKD11MzpbWSw3EIGhO7xUD4H0oY9+ddq/60Kk+lzaM8z1f1rKwKI/NwQk0kLbT+ATv9ky/JZ3GbKbjSYgit4IqRQPE44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712016914; c=relaxed/simple; bh=YOb6Of/mbUQtGB2+wiwG5V0/WzpW/exMJWy6vJJkw3E=; h=Date:Message-Id:Mime-Version:Subject:From:To:Cc:Content-Type; b=kDhS1f+02pIP2h8WAiuD0wosXoEXOk64ff+Yf6K3S1K4tiZEvNqiDj6jjmlv1Q7Toe6ElB51Nm1NRmr+oGn5R2kjx3N9UYgigVmbSCkTq3A0PdMPfF0Q0c3Ua0wf0TLztO32otLXG5lePkPU6w1kwEEC4GBfYzBfgfRMilPbhh0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pcc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vkdeewZ3; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pcc.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6144244c60cso43900067b3.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=vger.kernel.org; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=ObPEVpHNGOD9pdNTP5+iZiD9N6DasBI0eYYI9ayJs3Y=; b=vkdeewZ3wp1ZQeFN6qBKN/MTyrzr6LVFTccOlqPNQNiNPr5nOb79fpYfQY8J7Nn/xn qUZ0qmuzGVH43koiDPLBUtNLMJmpr7CtrQLcmLZ+OOFLLOz6g7SXHyELBFJP8KAY6mxf ln0XASEvSMEu8B5BbdVZMnJ+pjRwMk1aBC0EGash+cxu06eFcE8kY4QTACxBt3ih9wYP WJxyvrKU7Q+kwQqzCG8Lx5nAnN7/WThtL4sn9OY3bKgP42Y+osrdxawlZ6fXPU+RQ1wm 9Ywx2dl1zzDzLyFvV/N+UNrD2+wT782m5b2rpjy/P6Ts7+DiTdMxwmsYYSXe6K0XcEfq DuVQ== 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=P32ym0TdgoUVXFwSoRk4PkcbTkfU85dzR9VJZl2ULgNjzV2pejAvY2fVCSK7csavXW 8P/bIBVgaiVhlO78oAivgz/+2V9OiwsjPzaY7HH4mVvMxUsH1d6Mp1pE+8Yb3gbFtKX2 bJLWVG3wiXxwrJH65fk2j1KhdUiYCYDzWMN/DiTkgz4q4KLciCZQ0A0ZzSe1C2gJ8yS4 xizN40Y6Ni4o3jt69l1pHNUwVy/vvx1EPl6OJMsFsTdzl+NO5Q4gUf6qxeaEG0M6j2do qiBB0gY5iPDpUhYDtDorUX02QWD0qrzWa0EkeeXZsHHm3qMmzjIruqtrR9s/rakt4aNM xt5g== X-Forwarded-Encrypted: i=1; AJvYcCW49pN3532qEwN6ZNXm9bt2lrmrDZegXIO6ketn4u/SPf/95IlnSvPvfdx67V8QYDTiabkA5bW+XMbob+tcANkV1axTcBwAMeyDKQkR X-Gm-Message-State: AOJu0YwoXy/IyIE01XPfG49w3BYLKCi98JLT/PDczaTRhQasWXHPLwMg bzv6cLUJozi/TMzFDQ4FsLb6zXco6nDN36BqA8tuyFz4LsSSpwaJb1gHDskme8/U4Q== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Type: text/plain; charset="UTF-8" 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 --- 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; -- 2.44.0.478.gd926399ef9-goog