Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1329877lqm; Thu, 2 May 2024 11:15:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7LXtWKP/SXoqtXe6IAtRzqt5tWBAstQ0XNLft3UL3xMGJOS4MRLk12a7Y16vsH9q80DdGW+N7WYb5yjFabRmJEnGQJshyxXUMbDTfHA== X-Google-Smtp-Source: AGHT+IEROV6ouplHvVMtcMPcrY07jtKykuZaQoTzTIvo7xARe86pptc7yoOhG4ctCB0BBct28bi3 X-Received: by 2002:a05:620a:8228:b0:790:8c77:19b9 with SMTP id ow40-20020a05620a822800b007908c7719b9mr439581qkn.45.1714673717787; Thu, 02 May 2024 11:15:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714673717; cv=pass; d=google.com; s=arc-20160816; b=DXAjBoX9+YI4jxYvCYkOjYDEVf0KerB4nBwMnuDyNj1pdTp8ciOWdanBRVdJn47RVB +1y1w2NVq2XgXBbu95nKj/QSUVhfglcB+wvDxJWC4P/3/P+m9wwjN+n6z1009Vf2a1h+ RzJQIFLi1/N4ffL3Y8p1AdBvUW5K3z9fUewotzNhN5VSYoHq8lAEBgN+oNCNI9I044Te bbgVeftwHYZ1SoeYkc5pW8Sd07fUMNUbs4oJxiroF11364wqV1psQohbOvBkHeiwbf9H oYhhomSiv+6Cg1UmEGsIG4nWHH24qNoPtGYG8myVajLu0/RjAY1SvIZ+GgXbToxjw7Hw GaaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=jX8aKvbafhGbnZvdnKVSz/mpn0msgf30qB56G9DbOhQ=; fh=akANPXCY9sQXNxTPUDweWItZT7CajaBOLEDuPVUh9xY=; b=Z+7tMPEeZGVciFp8R+peLcYjuqgdL9oGB6FnhbUMIHDuMFUD3Uam5R9tOnBt/xUUI5 75vwjraisO1F/Jdz5aEQF0V9QB28bQ3FJcYb1x8Fb9SvpthykYW1rR5psmT1M/9h3P4f AuF5RjHDqRBztzvqo9EwYqzvjF0h/puxiU0W2Nhh4q+/JK4StiejMmkOThbW1iI+k+HK 9dZ3vPWSfKp+1ujRsv1+LtmlmmxlYDRXjTp5o/qQXDN5JUw4JqRULQvkAzbLIzxUdu/u ZamRJq2XRLA0w1CkQnRELd60Fa0vrag8y4lIbSI252VBARDxvpt753Wu5iyRB2jZv7mQ pPpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166828-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id xr9-20020a05620a5cc900b0079088519822si1382736qkn.405.2024.05.02.11.15.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 11:15:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166828-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3A2351C22400 for ; Thu, 2 May 2024 18:15:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 045E317335B; Thu, 2 May 2024 18:15:06 +0000 (UTC) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.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 33F6016FF2B; Thu, 2 May 2024 18:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714673705; cv=none; b=gBLHwoOd9sumAw0v35mcTLHEEct21/YdYzFg1mn568gKFY71fHtWGjiZLPjNTfG5asNoeGhrwxkf6FxAb7L26/w7yX7zPE02YpYYdevjiq3zyEDZGk6v2b6ReRmWuu6ljmgCmp3YtmGPn+r8UAVI6B3e6jcKBzUri9eeuXNUOPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714673705; c=relaxed/simple; bh=ZA92IXsc0X3IgFWFWIxdK48Y8F36zabbvP6VZiHZCog=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=AsYIMekkiDmPtItxkeLHK2udJeI8olDZMmOQTPmeuOymHUnv476TcTuw+VnNFMHQzaSTHV0a6sdOf9MEBuhHp5Td+CmTUfmkBm2iLFXroaJujYKUWzLwHNb5ZBmzvCo5j/cw5MZvbgm/vI1bzQPs5pi9Fzd5Vy9ONiIwXYUJnPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2ad8fb779d2so6652876a91.0; Thu, 02 May 2024 11:15:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714673702; x=1715278502; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jX8aKvbafhGbnZvdnKVSz/mpn0msgf30qB56G9DbOhQ=; b=m4AjLkZwcMEUaEJbiLcPW1I+HhN0n2AOr6yG+CcY3vfEVAdEzRmE8mEZ8mVxH8U0YK k0nFWjZwjBP3E6zM7tV8paMAjsqphVwLMms1USEZEPG1/124N+WPznxmUQzSi/CJYcHo oyj0JDJaSXiU1/myBStaFnvsdvLnELwJ9A3PuYI7FeTzzAARtmAQNp1T3Z7vopjAHO8v ieuEd+9zvc9Zx0IMgfpabOQN6GazsHmV9O5ly2GfWe9IWmBKa2cuykoXkWyF385VL5tc KcUXnGHUHIqjF41fcdnprcnxWxiPn/+2nMubKzzuYTLeSps2eAavs2y+pU4bo8EzNEmA 2XvA== X-Forwarded-Encrypted: i=1; AJvYcCWo27RR0zZTWIScnoaM3ytUsXFWFvsJRQxreKCm9LN71b0xHjd0wZBvLLuMkVgW+EXb7Tx+sDl8kAbZ7KIbAaPM+jq5m5XE9ZoFzkC0JoweyB9iSN9r9XgZ/dIGcBGW/pfhfOZFuz1EjHnOdMlKgQ== X-Gm-Message-State: AOJu0YyJTxM0pWx6gbb9PmgcPc3nxFK9VYup92Bjct1Xt4M+VRbF1Rl7 qc0cCxQDVOM2ge52daL2325wIu4Kqs+66HhpRk9dVl0SdTRwvChXJNvyMXK0Fxdh1bCs6B07LdZ mIIiN6p6bedzfpHFzbMHtw/HVxdI= X-Received: by 2002:a17:90a:c697:b0:2b2:32c2:44b4 with SMTP id n23-20020a17090ac69700b002b232c244b4mr635207pjt.10.1714673702312; Thu, 02 May 2024 11:15:02 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240502060011.1838090-1-namhyung@kernel.org> <20240502060011.1838090-5-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Thu, 2 May 2024 11:14:50 -0700 Message-ID: Subject: Re: [PATCH 4/6] perf annotate-data: Check memory access with two registers To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Kan Liang , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 2, 2024 at 7:05=E2=80=AFAM Arnaldo Carvalho de Melo wrote: > > On Wed, May 01, 2024 at 11:00:09PM -0700, Namhyung Kim wrote: > > The following instruction pattern is used to access a global variable. > > > > mov $0x231c0, %rax > > movsql %edi, %rcx > > mov -0x7dc94ae0(,%rcx,8), %rcx > > cmpl $0x0, 0xa60(%rcx,%rax,1) <<<--- here > > > > The first instruction set the address of the per-cpu variable (here, it > > is 'runqueus' of struct rq). The second instruction seems like a cpu > > You mean 'runqueues', i.e. this one: > > kernel/sched/core.c > DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); > > ? Right, sorry for the typo. > > But that 0xa60 would be in an alignment hole, at least in: > > $ pahole --hex rq | egrep 0xa40 -A12 > struct mm_struct * prev_mm; /* 0xa40 0x8 *= / > unsigned int clock_update_flags; /* 0xa48 0x4 *= / > > /* XXX 4 bytes hole, try to pack */ > > u64 clock; /* 0xa50 0x8 *= / > > /* XXX 40 bytes hole, try to pack */ > > /* --- cacheline 42 boundary (2688 bytes) --- */ > u64 clock_task __attribute__((__aligned__(= 64))); /* 0xa80 0x8 */ > u64 clock_pelt; /* 0xa88 0x8 *= / > long unsigned int lost_idle_time; /* 0xa90 0x8 *= / > $ uname -a > Linux toolbox 6.7.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Mar 27 16= :50:39 UTC 2024 x86_64 GNU/Linux > $ This would be different on kernel version, config and other changes like backports or local modifications. On my system, it was cpu_stop_work.arg. $ pahole --hex rq | grep 0xa40 -C1 /* --- cacheline 41 boundary (2624 bytes) --- */ struct cpu_stop_work active_balance_work; /* 0xa40 0x30 */ int cpu; /* 0xa70 0x4 */ $ pahole --hex cpu_stop_work struct cpu_stop_work { struct list_head list; /* 0 0x10 */ cpu_stop_fn_t fn; /* 0x10 0x8 */ long unsigned int caller; /* 0x18 0x8 */ void * arg; /* 0x20 0x8 */ struct cpu_stop_done * done; /* 0x28 0x8 */ /* size: 48, cachelines: 1, members: 5 */ /* last cacheline: 48 bytes */ }; > > The paragraph then reads: > > ---- > The first instruction set the address of the per-cpu variable (here, it > is 'runqueues' of type 'struct rq'). The second instruction seems like > a cpu number of the per-cpu base. The third instruction get the base > offset of per-cpu area for that cpu. The last instruction compares the > value of the per-cpu variable at the offset of 0xa60. > ---- > > Ok? Yep, looks good. Thanks, Namhyung