Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1645573pxp; Thu, 17 Mar 2022 13:30:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn12Ae3oxtnrWlWw03vvkQcQp5jf9nsGAnTUWNCA35Bq7FOE0x/QDPUiZ+L2nqJIb8hLRS X-Received: by 2002:a17:902:8f94:b0:151:64c5:7759 with SMTP id z20-20020a1709028f9400b0015164c57759mr6601854plo.4.1647549008381; Thu, 17 Mar 2022 13:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647549008; cv=none; d=google.com; s=arc-20160816; b=EnH2C/UiHxk39tQ500BH7zvH6T+klYtBHJa5Ga99dyeIqpmrZj2wyRZuXg1AXNIXkG ORm9v17VZgp3brtOnvvv4gGmRkDfUC7P/YYIkq+3Q+jZ5M/f5X23VXWT+o9oumV0H8zG ytiII0fEXG06tc453YRAACdIxHDRnYCVQwge/UmsZjJgaI/wAsgrX91hyEJxJWh3Y1aS QlCsyEVmi6hP2Kdgn8KYH/D4k/m3yExUwVtyw0GaDHfceHlkGHEGLontgvOwzVbGp7m6 fHf3k0a1T3X3rrR83PkH+BKp8XRkm2EW7LinfXfh0/oZhZfhwKd1hU7+MwHgTvQGYK+j Sb2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=TqKKeUEg+hnBu1qk6huhztmtUmj2PyTTObciyrZOsAY=; b=AlJvdbcAPPOggkY9OXtOMM4HrRBXqZEUBiHNGHpQFr3oXIiDLUeLABQOFkrMFRG6qK ETaj5IooaRltl8R4XsSKNrn7LTRDCgWZ2Fipk25Tfl3ROvc1wBryn04mG1D8SwPs6P0C Xw7XfbEk5IY4ASUH+zZdNpl6BBpdWja/6smJPjANvYh2yP7dLsiUQw2CYrXbnG+kvDCA rwN/OEU8yfDx/UWpk0YSgprwkqAEJfeKO52v78HBZjVNhXrtjGW96YgacN0/WVXouJnn QVw2RLlFyVUt2TE/146kBlV/NueE6MS4f5jgE3UdTuKB343+FRRWtF4MNR3kf8g3cpZL wbow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h11-20020a170902eecb00b00153b2d165d2si75255plb.474.2022.03.17.13.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 13:30:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D1D802CAD9C; Thu, 17 Mar 2022 13:05:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237107AbiCQR4X (ORCPT + 99 others); Thu, 17 Mar 2022 13:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232658AbiCQR4T (ORCPT ); Thu, 17 Mar 2022 13:56:19 -0400 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 006F017ECFC; Thu, 17 Mar 2022 10:55:01 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0V7Sm1Zs_1647539695; Received: from IT-C02W23QPG8WN.local(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0V7Sm1Zs_1647539695) by smtp.aliyun-inc.com(127.0.0.1); Fri, 18 Mar 2022 01:54:57 +0800 Subject: Re: [RESEND PATCH 2/2] perf/x86: improve the event scheduling to avoid unnecessary pmu_stop/start To: Peter Zijlstra , Stephane Eranian Cc: Stephane Eranian , Wen Yang , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Thomas Gleixner , mark rutland , jiri olsa , namhyung kim , borislav petkov , x86@kernel.org, "h. peter anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220304110351.47731-1-simon.wy@alibaba-inc.com> <20220304110351.47731-2-simon.wy@alibaba-inc.com> <0c119da1-053b-a2d6-1579-8fb09dbe8e63@linux.alibaba.com> <271bc186-7ffb-33c8-4934-cda2beb94816@linux.alibaba.com> From: Wen Yang Message-ID: <05861b8c-2c7c-ae89-613a-41fcace6a174@linux.alibaba.com> Date: Fri, 18 Mar 2022 01:54:55 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 ?? 2022/3/14 ????6:55, Peter Zijlstra ะด??: > On Thu, Mar 10, 2022 at 11:50:33AM +0800, Wen Yang wrote: > >> As you pointed out, some non-compliant rdpmc can cause problems. But you >> also know that linux is the foundation of cloud servers, and many >> third-party programs run on it (we don't have any code for it), and we can >> only observe that the monitoring data will jitter abnormally (the >> probability of this issue is not high, about dozens of tens of thousands of >> machines). > > This might be a novel insight, but I *really* don't give a crap about > any of that. If they're not using it right, they get to keep the pieces. > > I'd almost make it reschedule more to force them to fix their stuff. > Thank you for your guidance. We also found a case in thousands of servers where the PMU counter is no longer updated due to frequent x86_pmu_stop/x86_pmu_start. We added logs in the kernel and found that a third-party program would cause the PMU counter to start/stop several times in just a few seconds, as follows: [8993460.537776] XXX x86_pmu_stop line=1388 [cpu1] active_mask=100000001 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802a877ef302, hw.period_left=0x7fd578810cfe, event.count=0x14db802a877ecab4, event.prev_count=0x14db802a877ecab4 [8993460.915873] XXX x86_pmu_start line=1312 [cpu1] active_mask=200000008 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0xffff802a9cf6a166, hw.period_left=0x7fd563095e9a, event.count=0x14db802a9cf67918, event.prev_count=0x14db802a9cf67918 [8993461.104643] XXX x86_pmu_stop line=1388 [cpu1] active_mask=100000001 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0xffff802a9cf6a166, hw.period_left=0x7fd563095e9a, event.count=0x14db802a9cf67918, event.prev_count=0x14db802a9cf67918 [8993461.442508] XXX x86_pmu_start line=1312 [cpu1] active_mask=200000004 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=2, hw.prev_count=0xffff802a9cf8492e, hw.period_left=0x7fd56307b6d2, event.count=0x14db802a9cf820e0, event.prev_count=0x14db802a9cf820e0 [8993461.736927] XXX x86_pmu_stop line=1388 [cpu1] active_mask=100000001 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=2, hw.prev_count=0xffff802a9cf8492e, hw.period_left=0x7fd56307b6d2, event.count=0x14db802a9cf820e0, event.prev_count=0x14db802a9cf820e0 [8993461.983135] XXX x86_pmu_start line=1312 [cpu1] active_mask=200000004 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=2, hw.prev_count=0xffff802a9cfc29ed, hw.period_left=0x7fd56303d613, event.count=0x14db802a9cfc019f, event.prev_count=0x14db802a9cfc019f [8993462.274599] XXX x86_pmu_stop line=1388 [cpu1] active_mask=100000001 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=2, hw.prev_count=0x802a9d24040e, hw.period_left=0x7fd562dbfbf2, event.count=0x14db802a9d23dbc0, event.prev_count=0x14db802a9d23dbc0 [8993462.519488] XXX x86_pmu_start line=1312 [cpu1] active_mask=200000004 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=2, hw.prev_count=0xffff802ab0bb4719, hw.period_left=0x7fd54f44b8e7, event.count=0x14db802ab0bb1ecb, event.prev_count=0x14db802ab0bb1ecb [8993462.726929] XXX x86_pmu_stop line=1388 [cpu1] active_mask=100000003 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=2, hw.prev_count=0xffff802ab0bb4719, hw.period_left=0x7fd54f44b8e7, event.count=0x14db802ab0bb1ecb, event.prev_count=0x14db802ab0bb1ecb [8993463.035674] XXX x86_pmu_start line=1312 [cpu1] active_mask=200000008 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0xffff802ab0bcd328, hw.period_left=0x7fd54f432cd8, event.count=0x14db802ab0bcaada, event.prev_count=0x14db802ab0bcaada Then, the PMU counter will not be updated?? [8993463.333622] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802abea31354 [8993463.359905] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802abea31354, hw.period_left=0x7fd5415cecac, event.count=0x14db802abea2eb06, [8993463.504783] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802ad8760160 [8993463.521138] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802ad8760160, hw.period_left=0x7fd52789fea0, event.count=0x14db802ad875d912, [8993463.638337] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802aecb4747b [8993463.654441] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, [8993463.837321] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802aecb4747b [8993463.861625] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, [8993464.012398] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802aecb4747b [8993464.012402] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, [8993464.013676] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802aecb4747b [8993464.013678] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, [8993464.016123] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802aecb4747b [8993464.016125] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, [8993464.016196] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802aecb4747b [8993464.016199] x86_perf_event_update [cpu1] active_mask=30000000f event=ffff880a53411000, state=1, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, ...... Until 6 seconds later, the counter is stopped/started again?? [8993470.243959] XXX x86_pmu_stop line=1388 [cpu1] active_mask=100000001 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0x802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, event.prev_count=0x14db802aecb44c2d [8993470.243998] XXX x86_pmu_start line=1305 [cpu1] active_mask=200000000 event=ffff880a53411000, state=1, attr.type=0, attr.config=0x0, attr.pinned=1, hw.idx=3, hw.prev_count=0xffff802aecb4747b, hw.period_left=0x7fd5134b8b85, event.count=0x14db802aecb44c2d, event.prev_count=0x14db802aecb44c2d [8993470.245285] x86_perf_event_update, event=ffff880a53411000, new_raw_count=802aece1e6f6 ... Such problems can be solved by avoiding unnecessary x86_pmu_{stop|start}. Please have a look again. Thanks. -- Best wishes, Wen