Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp7675imm; Fri, 13 Jul 2018 15:51:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmsbItF89JiPWUAcOPazLkeekar5BiZvA5EMAuXSRyj+xfuQO2xsG4AQI62N31j8xKYj5G X-Received: by 2002:a63:e914:: with SMTP id i20-v6mr7703094pgh.10.1531522310913; Fri, 13 Jul 2018 15:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531522310; cv=none; d=google.com; s=arc-20160816; b=0Uc7v+Hll3v4EFDLUPDVXWmrr2gJrACjMR5x2Cpq7MrTapioF8x60lTCH/dC8uVS11 s99W4bCfJmEQKoc8akZd52IDyKZrCGOxxUshbZoPt1ztO0gLm8qeGUIPm/bgZRW1LyvB plPOkmz8txdfQE7pj1A1MxNdDWaTsrX8TQSbzGOqPZW+DM69N4Xe0o+sbPHxP5Ap8sks KhyuO98Gv3jpk2w3OVl+WGjtfQ+eY1Q7G6HCmdeCZQFxT7nFx5rXgIhUL0cORDEFHhNV pPBbFjduNUlt+yfpLelmvJV+7EuUAIYYiO4UDS/InodceDet3m7D7oV7LJSIOjopKheA V4Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature:arc-authentication-results; bh=bnariFpju5boGLaI1TyTX/wwJHjG2/05GNftLn6KdWE=; b=F4IBkpmNvfxgKvAHIkmBEfXXkmpl1PIpwMy4nazKx5mLFqPDeMBQdIsqMnYHgQ3F/7 lBYZu8pyMpcFxMK0EisUzFn0D+kFwltt1EJ4xqLlVHvEVdffTJO0boKXz9MkooGJs68x z/cWo+mwH3PLSe+SV6HeHk4l+uyz2RiGdlaK3dvrFsBJNCI1r/z59ZDqBrlnEQsDAqWn je+dKnSyc3xp84tZ3D0ErOIa5yr3tbVxNR+II/O25wB99xn3aG71p2Hcvci3GIfLZrmz q2/k+VRO6gklHc0wbYfXqEKDx/QbznKhxzzqvFrF1176qtxiGp/HhXHS6d+Fyjs4FwNf ySGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DQSfeQjJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q68-v6si27252914pfl.317.2018.07.13.15.51.12; Fri, 13 Jul 2018 15:51:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DQSfeQjJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731555AbeGMXF1 (ORCPT + 99 others); Fri, 13 Jul 2018 19:05:27 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:41674 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727188AbeGMXF1 (ORCPT ); Fri, 13 Jul 2018 19:05:27 -0400 Received: by mail-pf0-f195.google.com with SMTP id c21-v6so18776063pfn.8 for ; Fri, 13 Jul 2018 15:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=bnariFpju5boGLaI1TyTX/wwJHjG2/05GNftLn6KdWE=; b=DQSfeQjJgdg5FrQZ5SdsRePjtmoLCJWAmBwTzrI5v8IUs7X4MCw5enA94J9/6LWKbC Qkny1HZcIIjo1hc7+B0cXEB+XQwHtcVbRuzQtX8EKvHvLWNyRXUicbjbq+WwiASdvoLs qLvWAIRs/lRGJa41z25WHOyKJCJFIlBi01yHMF7FwnGqwYfyAJfrIcozXdVpBw6XeeNJ ex0FGuLm9yW0Zr+4QapsRo6lfzce/ETcQ4/Qt0qoBxwzPefnYdiFaTf8Wc4u/JGbIrQ/ cmvnpezWePV9GicU0OfSsQGVepQO2LcRrZSHzG08tX4HQc0tZFNsNvGm2MZOxv5CgHxy jJCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=bnariFpju5boGLaI1TyTX/wwJHjG2/05GNftLn6KdWE=; b=dyWvXD/bIKlDdJg7+z8RvFvO3SfccZZAu0NDI+1X7MQxAKV5K1EkILzvEf/6qeTN4S zqvDGpKjOTwmruBNBYEJN5blV4QakkhXxCqRaTurNRFAynS+9/ovIN0HFqp0YS4b7MJN BYK/UYRaBiOadFNSFdXDxVOZLc12Gp4SzAfUMccK8wUCuIcbfu0hlYGHtnW1B1BQkbgp djBhbvxeQQp3xroWFGXHpch2s4Bn+1MvyjbcsYcIWsEmUb/GN+lwalZ6oRaY7CYYsHWJ ppIinLXQGM6RRrOa84+4U6Nn4/6zmeYIf1V1UpUgd7xK3loEqCNU/jww1SuXt6DXQf8X 18cg== X-Gm-Message-State: AOUpUlG57mG6yQ/nc/IOu4hL3VMpZ+WwZNhs9ykvGyOXc5NAHCdRNljp a23hzlO4gAVD81q2O7NqAnB0Nw== X-Received: by 2002:a65:5bc4:: with SMTP id o4-v6mr7640586pgr.448.1531522127402; Fri, 13 Jul 2018 15:48:47 -0700 (PDT) Received: from [100.112.85.58] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id v3-v6sm91468801pgb.54.2018.07.13.15.48.46 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jul 2018 15:48:46 -0700 (PDT) Date: Fri, 13 Jul 2018 15:48:39 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Ingo Molnar cc: Thomas Gleixner , "Metzger, Markus T" , Peter Zijlstra , Arnaldo Carvalho de Melo , "Shishkin, Alexander" , "Kleen, Andi" , "Hansen, Dave" , Stephane Eranian , linux-kernel@vger.kernel.org Subject: x86/events/intel/ds: Fix bts_interrupt_threshold alignment Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Markus reported that BTS is sporadically missing the tail of the trace in the perf_event data buffer: [decode error (1): instruction overflow] shown in GDB; and bisected it to the conversion of debug_store to PTI. A little "optimization" crept into alloc_bts_buffer(), which mistakenly placed bts_interrupt_threshold away from the 24-byte record boundary. Intel SDM Vol 3B 17.4.9 says "This address must point to an offset from the BTS buffer base that is a multiple of the BTS record size." Revert "max" from a byte count to a record count, to calculate the bts_interrupt_threshold correctly: which turns out to fix problem seen. Fixes: c1961a4631da ("x86/events/intel/ds: Map debug buffers in cpu_entry_area") Signed-off-by: Hugh Dickins Reported-and-tested-by: Markus T Metzger Cc: # v4.14+ --- arch/x86/events/intel/ds.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- 4.18-rc4/arch/x86/events/intel/ds.c 2018-06-03 14:15:21.000000000 -0700 +++ linux/arch/x86/events/intel/ds.c 2018-07-12 17:38:28.471378616 -0700 @@ -408,9 +408,11 @@ static int alloc_bts_buffer(int cpu) ds->bts_buffer_base = (unsigned long) cea; ds_update_cea(cea, buffer, BTS_BUFFER_SIZE, PAGE_KERNEL); ds->bts_index = ds->bts_buffer_base; - max = BTS_RECORD_SIZE * (BTS_BUFFER_SIZE / BTS_RECORD_SIZE); - ds->bts_absolute_maximum = ds->bts_buffer_base + max; - ds->bts_interrupt_threshold = ds->bts_absolute_maximum - (max / 16); + max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE; + ds->bts_absolute_maximum = ds->bts_buffer_base + + max * BTS_RECORD_SIZE; + ds->bts_interrupt_threshold = ds->bts_absolute_maximum - + (max / 16) * BTS_RECORD_SIZE; return 0; }