Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3894716pxp; Wed, 23 Mar 2022 07:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2tlfi7Zx1PinUN3zXOREjmN6sP6JaHYlW7YaKLykPhbeUDdykkcL0OhPgfREDmQP8dtEV X-Received: by 2002:a17:907:7b8b:b0:6da:bad3:88b6 with SMTP id ne11-20020a1709077b8b00b006dabad388b6mr321974ejc.360.1648046768395; Wed, 23 Mar 2022 07:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648046768; cv=none; d=google.com; s=arc-20160816; b=QtYVxCuKBR/feFvK3dX96kibGIK3bpLdkzMJT1ITEw3Km4he2uabnNolDQjSI6LdAf y/0HB6RS0mxCfjWG0+zqFXTGbVXGuZkenyv4NGmspN59qn1ZAivhKCsbgNpaTkbZ7uMw xnkgaGQrRacRwazKz/jhu/lf4TLZ8pwFmZpXbxQZ/48WZwR0RNGmeFwbv/PF+PVcECda mtbyzmAYUFEDxvk6Brw7cKpz4Av88gKLrWReMtaO29SDe/VmFvgExotLoK+2XxoHBEUT 2cbU2lelN3FY6rwqqrRhlo+WJGG40gJhZ7S+epy8PwN9HLdLl6TXrqXu1hFJMYxraHWr wsGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2ggSoRFKh0G1dKQFttVqUzAVwqtOX7Y3mA+081Turu8=; b=Kkz6ARZt1+ouVhett9uOuBSr2bqdNUKlugx+1cXw3Jd/1qHtmJ9a/O6Vv0viF9HD6D L3MzcIJEF+wbSIVp2/peLwS91ZY0ArHLk1OynybcpT7lru+p7eo7Cm9S4WsswYWpFi2s tcF5FatIwFcnAc4xalhfMQ/TirAIeXOTKi7DdP7Fzn5b+BALrBAbZGQH3k5O9zEr8fat 3o7zOamZXLVSIPRN0+5FwOx1Nwcev7oe2qZf7fMOEUYan5lOjDut45pJ/8BB+p+zbE6K R9U+86hGnfuTf3ICxG5+K9hBGux5OerJV0X8U8OmSyV+L4elPJWiS0DxeDnjPYgbu4eK vVDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=FKjxn9u6; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a170906c41000b006df76385e04si11741711ejz.676.2022.03.23.07.45.30; Wed, 23 Mar 2022 07:46:08 -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=@infradead.org header.s=desiato.20200630 header.b=FKjxn9u6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242489AbiCWIQO (ORCPT + 99 others); Wed, 23 Mar 2022 04:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242182AbiCWIPu (ORCPT ); Wed, 23 Mar 2022 04:15:50 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722C66D386; Wed, 23 Mar 2022 01:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=2ggSoRFKh0G1dKQFttVqUzAVwqtOX7Y3mA+081Turu8=; b=FKjxn9u6R6LAfSreq3RMO6doF6 A0j/KB+lvNGml3FUMTFXmgJkNs+r0bBuJaGeRAula1+PNsamC5OAg4qoenHSt9BP0/kXlo33UPnU/ nzp3dGtEb5IliJq2XCFNOnyciMB38Z7tkbeJYnZ9P/+xsMRKlWlbIeXUX2uo7VLopSCcygg7RVytp X6RurDqZaEpj+EaawH2VrEMo1hPiS+4LsysZ41GUTLffegC6sp11jJRvrNloxBMEFsE+qDLdWk3oB FjN92v/BMIgGIGSw1vLxLJM0NhHqRshwG/zZeL9meYjUIxlG7F914YxT1F+5mDGafJq+x4X1JF5nY sMvY8e5Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWw80-003hq3-9v; Wed, 23 Mar 2022 08:14:00 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 777D93000E6; Wed, 23 Mar 2022 09:13:58 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 565EE20C5903E; Wed, 23 Mar 2022 09:13:58 +0100 (CET) Date: Wed, 23 Mar 2022 09:13:58 +0100 From: Peter Zijlstra To: Chengming Zhou Cc: mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, eranian@google.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, songmuchun@bytedance.com Subject: Re: [External] Re: [PATCH v2 2/6] perf/core: Introduce percpu perf_cgroup Message-ID: References: <20220322120834.98637-1-zhouchengming@bytedance.com> <20220322120834.98637-3-zhouchengming@bytedance.com> <0a7ebd49-cfdd-911e-3982-44f594320b0f@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0a7ebd49-cfdd-911e-3982-44f594320b0f@bytedance.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 On Wed, Mar 23, 2022 at 12:33:51AM +0800, Chengming Zhou wrote: > On 2022/3/22 9:01 下午, Peter Zijlstra wrote: > > On Tue, Mar 22, 2022 at 08:08:30PM +0800, Chengming Zhou wrote: > >> Although we don't have incosistency problem any more, we can > >> have other problem like: > >> > >> CPU1 CPU2 > >> (in context_switch) (attach running task) > >> prev->cgroups = cgrp2 > >> perf_cgroup_sched_switch(prev, next) > >> cgrp2 == cgrp2 is True > >> > > > > Again, I'm not following, how can you attach to a running task from > > another CPU ? > > Hi Peter, I make a little testcase which can reproduce the race > problem, on system with PSI disabled. Because when PSI enabled, > cgroup_move_task() will hold rq lock to assign task->cgroups. No, the problem is that you're talking about cgroup attach while I'm thinking of attaching a event to a task. And your picture has nothing to clarify. Those pictures of yours could really do with a few more function names in them, otherwise it's absolutely unclear what code is running where.