Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3942683ybg; Mon, 21 Oct 2019 01:00:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlNpv29kqFUkzGlaSP9TITuQJoIrRYpc8VgOaM7xrtDVmtnpB55ibQhCH5zvuLGBDaiAA4 X-Received: by 2002:aa7:dd0a:: with SMTP id i10mr23393875edv.189.1571644820897; Mon, 21 Oct 2019 01:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571644820; cv=none; d=google.com; s=arc-20160816; b=sZ5l+27PWY/tc6Z+yz+jHBE79LH2IBscbCK0Vw4J9zKq4rEZ7tB21wEnbJONpEjJw3 566EZl9TjqpCB1MpEkJTlg69eVQcAlQT1hD2oVyBAlzQD3yNh0yVFB153ViOFRBklmAg 8Q8qgacb+NFrSuqckwvSvE3QaaWJinagaSIFqp/ixUyVGnPNRNakiq9N78QLPykwc8MK odMz8LSw6nWmakiaHYgrEcfoJ1DkoCmkLJ4clagTxjjuyOFnuAnur3jL8qBYk+9FP22n 8eHvdDapy0Q2V/rD34vASy0Jp001G6F2j0fNv5129gihtdkJcM+XFgri9pkajbwcgWPe 6poA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dusALXNtOXXNZZZbyl/xMwyt1ewPplJLSYZZzGVsFtQ=; b=fo+Z1Kn5+QCuH7jl5SdvN8FFuOWniJ+JBVJLLHjWv75yfkT2xzbF3l2CAE75n4JF2z XMzWrwRVKqozo8AMlWmcQXc1Zcc8YK2k81lbXcjypPyvppzLLYZ2Mrqqm8GmrflcK4oS xHIGOrBA991Kr/edt3W6dI/Sq3ho9H13vPwDseqNSxrvHjQcugq3e+heskNk/7fSCfSR RmIrN8aI6z2eM13yP2nnFFjKVjOqkc5RVUamXax34A+voTMES8W2UKZGGnbX+y1h23Os YX+NzRmwOK2gd7ErzONh0Mup1e/UG8c6q/g3k/MYuW+iIgzFG9j2plIMzCMhn91sj4Ib jXJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qiafQ9k1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b27si9388233ede.233.2019.10.21.00.59.57; Mon, 21 Oct 2019 01:00:20 -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=fail header.i=@gmail.com header.s=20161025 header.b=qiafQ9k1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727500AbfJUH7s (ORCPT + 99 others); Mon, 21 Oct 2019 03:59:48 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36239 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbfJUH7r (ORCPT ); Mon, 21 Oct 2019 03:59:47 -0400 Received: by mail-wr1-f68.google.com with SMTP id w18so12145968wrt.3 for ; Mon, 21 Oct 2019 00:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dusALXNtOXXNZZZbyl/xMwyt1ewPplJLSYZZzGVsFtQ=; b=qiafQ9k1U2DEi5MXUxnyA2elBLak4Jl7I2nvYPbcwxYvjPnfosv9ThSnvwmRa7miPt FnQGp0dEFOCpG7XAosjMZNVbRZcFIxD5F+ZMDLde90azxVFLhdK9C3rbOPvkeVit979k 4z1coeQPD6A08SVYYE9Lt4SYYaC3UEyEp5Vkfsp+/u3UvWNW6yLt4AeVFyGr/YaunX/t WatGQADyAaQEK7HyiNFd2a5ByhSYLkC1gVQG1uxKI735ZwEj2htzEkPpB8zlgVe3nDq+ KVYFUMJ6+6ay2fAGY/GakrO5JyHpmlnQ3Jz6HpTNcM8gDl10wc7aoUlZQU96r425a2k4 6hxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=dusALXNtOXXNZZZbyl/xMwyt1ewPplJLSYZZzGVsFtQ=; b=UtbdstpbvGdVCs9qrbqy1CYjAwPbIrWLRg/luctxMWCzNTDmyULNmyBgDp33AQQebQ XF4cA4uR1xzN6S2pqYHrwEIJfHzNt2deuQ1slFbbmDMn37zcsY7RVmxxQs4Mup5MEksu LMApU4lTT0jRBHBbOZm1y3vnKrkZz4HWWAGfnwkYt1wDQMD1xZM7xjksO0f4kBNtCq6w s7esinbeqJykkMoHAdCBpBZf6l/tkde3+pnw5ftPD0cRJ78xtSO8T8+Qpdt3O8Cms5O3 Z/Hzc3cEps2rO8vD9hua5+zZx5xdKX1ukFHsSYrcDBoAPNQnw3aUGsTMx6zMK4UrIWgP 4K6w== X-Gm-Message-State: APjAAAX/pXHc3JfcrxxLcJUKOopA5yCBLb0w6H2X1msqtA31UIgytmz2 i3pf3pyX0S9uO5G2kSicVomIkh6R X-Received: by 2002:a5d:638f:: with SMTP id p15mr9417011wru.150.1571644785585; Mon, 21 Oct 2019 00:59:45 -0700 (PDT) Received: from gmail.com (54033286.catv.pool.telekom.hu. [84.3.50.134]) by smtp.gmail.com with ESMTPSA id z9sm13901595wrv.1.2019.10.21.00.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 00:59:45 -0700 (PDT) Date: Mon, 21 Oct 2019 09:59:42 +0200 From: Ingo Molnar To: Alexey Budankov Cc: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , Kan Liang , Stephane Eranian , Ian Rogers , Song Liu , linux-kernel Subject: Re: [PATCH v3 4/4] perf/core,x86: synchronize PMU task contexts on optimized context switches Message-ID: <20191021075942.GA8809@gmail.com> References: <0b20a07f-d074-d3da-7551-c9a4a94fe8e3@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Alexey Budankov wrote: > + /* > + * PMU specific parts of task perf context may require > + * additional synchronization, at least for proper Intel > + * LBR callstack data profiling; > + */ > + pmu->sync_task_ctx(ctx->task_ctx_data, > + next_ctx->task_ctx_data); Firstly, I'm pretty sure you never run this on a CPU where pmu->sync_task_ctx is NULL, right? ;-) Secondly, even on Intel CPUs in many cases we'll just call into a ~2 deep function pointer based call hierarchy, just to find that nothing needs to be done, because there's no LBR call stack maintained: + if (!one || !another) + return; So while it's technically a layering violation, it might make sense to elevate this check to the generic layer and say that synchronization calls by the core layer will always provide two valid pointers? Thanks, Ingo