Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2459929rwa; Mon, 22 Aug 2022 08:05:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR4So7vkzRgAA/IDi1m7FLTyC8Lc+tue/2nCRnqJQ6eCUpYsEmqU0F9hT86TT38WuMVK9ccI X-Received: by 2002:a17:906:9b09:b0:73d:7c69:4d6a with SMTP id eo9-20020a1709069b0900b0073d7c694d6amr3994820ejc.531.1661180712095; Mon, 22 Aug 2022 08:05:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661180712; cv=pass; d=google.com; s=arc-20160816; b=lwPyQS9IrDF9uzsDmzrsu1wEiZx7D6sGpCDucPDjw+HgCodKfFYG0uBBiLhd68bgWN k+cw/HaBRB51y06vMJTJyUTwOKPs08vF/o2qCQ73pwKPinX1WRduW1JsVNgO24gCFLDh cWFLe3qRWcp/m+obhruJ+uX/Y+ituoI9zX7EI7tCpOVOonkT9hqdeMnth8lWtudzBGwr Ya9SbYYJrX0VN2/kv70ZFtt8Ef7zJi/qcvOhGN4GhZ185IHrhOsrVw9u4LHwCqKj1iBd yxWJcDn52suwiOeD22hu/YwfQMXEe3JgbMQiNXiVeDQlJJL1MgutjEJDwBWMS7HW6qTF 3s4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:content-language:references:cc:to:subject:from :user-agent:date:message-id:dkim-signature; bh=hOXkuhc74Mr9tG/QuIJJd2BI8rnG8efD6mZaq59yZ9c=; b=oun6dhqbiE1xJTm0ImKTHE3XFL0QfwsLQvvwjQxz8apJe5Dbo4mN8ex+JODctFGnt6 WVtPvwJmUBRw1Rv3kvy+wlHXvKszTHDsuV2EaRSFbBFbgBhnWXsNGbs5y4h39FeAI4/P +g5PXTylB9+EKm4Z4PUskDvUst6dBKYL41UJQ8q8BEi2ZN7ZjBsYIrdCXOoBjLfQHu0s +iHhyw+27SSOcllCmS5ND9WJCXvYo79Haw7oRTsmOr19bqAL05Z9uGgtRKg9RZY6UUrw FMPNAJnbmhcq3e/eNc7HeiyyD045yPOhxvdAiSlnJMpONWPn6wvCJmWL3jASqngM8w8r mNMw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1OzJmeZj; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs32-20020a1709072d2000b0073bc83b838bsi1271178ejc.281.2022.08.22.08.04.41; Mon, 22 Aug 2022 08:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1OzJmeZj; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234854AbiHVOit (ORCPT + 99 others); Mon, 22 Aug 2022 10:38:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233846AbiHVOir (ORCPT ); Mon, 22 Aug 2022 10:38:47 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2056.outbound.protection.outlook.com [40.107.94.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B21E1EAD5 for ; Mon, 22 Aug 2022 07:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eocmT5DDCnBfVzCgpROy8D/5QX9kRzQsLszmVS84sdRzxWaPGLLJCk7MZCQyy06PtyExuZ+9tnWkCXXkJfT0KgXEsBUxRPOkMWqveZ+5UjEX0tgyy5GMWRhjsA50HDkpzN5vag5eCWCYmvPuskpZWHHvEstCVU+s/cD71CjEOI6+KfIJ1OrsNF/67ZbWZBe9dbDPw6njMl0/fHiRhA56MicfF8c1fF+XuTR0/x5xciVfesdLBkqymOyxyGJ7mfYZ2Pi3xe4aw2Vf2Vug2WPxGWorwpcmxibIHIA+1ld69mn/n0tharf6Sch6PLLOSSHWdNYGu4VrdDpUCyEbNxaEGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hOXkuhc74Mr9tG/QuIJJd2BI8rnG8efD6mZaq59yZ9c=; b=eXW7n5S4tv4XD7A+bAVwYnDW8ZPA4YCMSs39UdHEpFi4G+Y2OqpRblhLQsfUzbz15G52DLXihm9Y6aczzf4+NNNKXAWqAmsLbHj46yrvz9piLypvnRNVFg/+jCzmqBBeaVaxb16plmhodLY8lubQ2ZKAKGiyJPbwwhGgOpRHqqtbiLhnEds0Yc3LjgN6BtFmi68DebHsEjeKcO5n1L0W7zYCLnEb62oik6bcbwet2WjZg2vi85fk24uXO7Nw0nZ42QqL3M9b5eRG1WIteES/HswdmFDc+R89U/I5fm6EqGbY9WBTPRbkZ093zOzLaiFvNjA7szI1FGhSsEFWMUyp6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hOXkuhc74Mr9tG/QuIJJd2BI8rnG8efD6mZaq59yZ9c=; b=1OzJmeZjh4TfpPuL3tRnkGr0NvkPiTq6W3mnGcK7aHINZZ3bxtmVuHQzzJmtGCyu95zgcOzD7xBC/UyCdNKUH22nEXqgC8xdFQ1OBxpCLXxFB1jB5tB5z8dcRqZGFAa1P6J+cGTXQuXx/wPjX4PWIPi6Z4JKRwmcnRkObpekeWI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB6588.namprd12.prod.outlook.com (2603:10b6:510:210::10) by BN6PR12MB1873.namprd12.prod.outlook.com (2603:10b6:404:102::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Mon, 22 Aug 2022 14:38:40 +0000 Received: from PH7PR12MB6588.namprd12.prod.outlook.com ([fe80::7d11:1ba2:dab0:bae3]) by PH7PR12MB6588.namprd12.prod.outlook.com ([fe80::7d11:1ba2:dab0:bae3%4]) with mapi id 15.20.5546.022; Mon, 22 Aug 2022 14:38:39 +0000 Message-ID: <5f2efe0f-fb81-3bed-3aa4-a3b15d823946@amd.com> Date: Mon, 22 Aug 2022 20:08:29 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 From: Ravi Bangoria Subject: Re: [RFC v2] perf: Rewrite core context handling To: Peter Zijlstra Cc: acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, songliubraving@fb.com, eranian@google.com, alexey.budankov@linux.intel.com, ak@linux.intel.com, mark.rutland@arm.com, megha.dey@intel.com, frederic@kernel.org, maddy@linux.ibm.com, irogers@google.com, kim.phillips@amd.com, linux-kernel@vger.kernel.org, santosh.shukla@amd.com, ravi.bangoria@amd.com References: <20220113134743.1292-1-ravi.bangoria@amd.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN3PR01CA0178.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:be::12) To PH7PR12MB6588.namprd12.prod.outlook.com (2603:10b6:510:210::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4489b810-49f2-422d-9105-08da844c00a9 X-MS-TrafficTypeDiagnostic: BN6PR12MB1873:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /0R0mhXPEEwp6YTYz3Ufky3pec5sS5a2v2I4Tq5M/GEx9gxLcPW/oJYOGkfSlMIQfrU+bH9xRtaU4hIfo1yd6uUlek+upbjvyW+0aNxgGtzrhrll8X2Dy0go2FpUFP9PneP1iCYV31PRUpQYcSWe2JMaXvX0qpZO4kR2j5iIOZIQkGvO9GVOLuAf9J+Fxz3N0haHg3B8joJpbV3JWrdj39vNARqPM7cxdhmJfHBlvFyJZHo7hcu369E0u3EBv2oiEY3UesG6amb1Y/WUzk5XofvCgiI8Bt8zm30PfjbNhS6WklHLEZgOeN4v1Coc9M6Ei3Rx6FRXPmO1gkv04yPkr7FTMOo0lvaeDZL2rzkLLLEokxoWuZBLjYmvQJO0/2ObRP/Isy2PddZ/4O7qFQgeMWKfT470ynWvZ1G4BJEg2pj2VjyD/U8u1vuwAKSh0SgtVQUICRPGSxqz6PfYfIFDnLuDGKVrsUlweXGnyJpfSpJEMFV5zezVs5O7PBKZD79M8rGw0MoE4WQOIMqcXhSuvxOIFvccE8dApWFdQTZmIYlEzpLCHqwPoPsVeFj/tn+PUmvfjF0r7lI07fQIqT6Wk88hfWnEwdp5Oqno7crtjoOjkreQP1MZNUgYHN2iw1P2mnUgOUfbS5j07huSWnuJ6txvC1mA7OLe5fF6YXU9VcakCKi6Y8XCCLJy7EdGP1xNLERm5X/zkBjGHWRZ7Ish9N8wxG1UpAUB0mZn2UXdqNyQdaxgCRJ3mIs6u1To6Dn7QHVOwzbokTlxlicUWmHL32vk47u8r5HKvtMYsppilCo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB6588.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(376002)(39860400002)(396003)(366004)(186003)(86362001)(31696002)(38100700002)(2616005)(66946007)(66556008)(66476007)(8676002)(4326008)(6506007)(8936002)(31686004)(316002)(6916009)(36756003)(7416002)(2906002)(44832011)(5660300002)(478600001)(6512007)(6666004)(41300700001)(6486002)(26005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZVdCQ3NrTnBMYWk2TVRNSlVjcUppUDhuUmkvNUJEL0d1Y2FXeTdOeU9tVWZs?= =?utf-8?B?OXFsbmUxV1A0N3pDbEEzVHJjY0Npd3JIZlM1eUdzMi91WG9MYXFtbUNEMWZn?= =?utf-8?B?R29CaDMwZDNMWDJlL3BYYm9sRFVDN0xxczdnOVQ5bHNhZkthbzFSYlRmWnRn?= =?utf-8?B?MHZoWjRBYVdhSG1PaGJNb0F4MWhzYnAxVnRKb2pqbGlJQmhzd2MxZTlSL2ZB?= =?utf-8?B?R3lvOUJxVVBmVFgybmxrRFF2Q2VBQkd1UDdHTlhtcC9kSVc2ZEdwbHh0UUEz?= =?utf-8?B?RmlhcVFwUFhiN2ErS0I4bEgzZk15Q0Nuck9SWGJkLzl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a?= =?utf-8?Q?1knZX3oTaVwA5ryWdKl3iTEwC?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4489b810-49f2-422d-9105-08da844c00a9 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB6588.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2022 14:38:39.6557 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p/gN7o+mBlz4/r2qwaMxDa3t80BcbNIPUmcWvnPOSclveOuZkS56d3JndRq+4/mYchxdL8ATb2apiUBNm3+O3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1873 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] > You mentioned trouble with cpc->task_epc, there's one rebase mistake > from you and an original bug from me. > > You lost the last hunk, I forgot to clear cpc on > perf_remove_from_context(). > > With these fixes I can run: 'perf test' without things going > insta-splat. > > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -2311,6 +2311,7 @@ __perf_remove_from_context(struct perf_e > struct perf_event_context *ctx, > void *info) > { > + struct perf_event_pmu_context *pmu_ctx = event->pmu_ctx; > unsigned long flags = (unsigned long)info; > > if (ctx->is_active & EVENT_TIME) { > @@ -2325,8 +2326,17 @@ __perf_remove_from_context(struct perf_e > perf_child_detach(event); > list_del_event(event, ctx); > > - if (!event->pmu_ctx->nr_events) > - event->pmu_ctx->rotate_necessary = 0; > + if (!pmu_ctx->nr_events) { > + pmu_ctx->rotate_necessary = 0; > + > + if (ctx->task) { IIUC, this should also check for ctx->is_active? i.e. if (ctx->task && ctx->is_active) { ... > + struct perf_cpu_pmu_context *cpc; > + > + cpc = this_cpu_ptr(pmu_ctx->pmu->cpu_pmu_context); > + WARN_ON_ONCE(cpc->task_epc && cpc->task_epc != pmu_ctx); > + cpc->task_epc = NULL; > + } > + } Thanks, Ravi