From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35F88C433ED for ; Tue, 28 Jul 2020 17:06:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B42ED20786 for ; Tue, 28 Jul 2020 17:06:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="LjI0g1LY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B42ED20786 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4C5C71713; Tue, 28 Jul 2020 19:05:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4C5C71713 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1595955960; bh=HJPSQD63CmYKFhXLZwHZPMkZR1gwNLCvXDxZjAkWuaY=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LjI0g1LYeeUaN4DPsVjoRGv8Y4l43ByRQZbArtYVdWukoW+X42bAzXkqNidZFA1Ys KLwiPhrgBhWlNFbJaHvLrxSGDh6qmpwgtsvT7LkltbrMedRhOurXgXcve7mJBRLJsM UFUOwaI1zRBdqo2EQC2ggAIcADnbIOzbl+CM+TRo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D048DF8021C; Tue, 28 Jul 2020 19:05:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4079AF80227; Tue, 28 Jul 2020 19:05:08 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E824DF800AD for ; Tue, 28 Jul 2020 19:04:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E824DF800AD X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 67D5FB155; Tue, 28 Jul 2020 17:05:08 +0000 (UTC) Date: Tue, 28 Jul 2020 19:04:57 +0200 Message-ID: From: Takashi Iwai To: Pavel Hofman Subject: Re: pcm_meter.c issue at s16_update In-Reply-To: <9957e124-be4b-cdc9-ffad-579b631455df@ivitera.com> References: <9957e124-be4b-cdc9-ffad-579b631455df@ivitera.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: "alsa-devel@alsa-project.org" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Tue, 28 Jul 2020 18:46:00 +0200, Pavel Hofman wrote: > > > Dne 26. 07. 20 v 20:20 Pavel Hofman napsal(a): > > Hi, > > > > I am debugging the following problem with the PCM METER API: > > > > An application with meter/scope configured in .asoundrc hits a high CPU > > load sometimes when a new playback stream is opened. E.g. in MPD when > > opening a new radio stream. The 100% CPU core load takes tens of seconds. > > ........... > > > > TL;DR: at decrease of [status.appl_ptr - status.delay] between > > consequent runs the size of buffer to convert by the built-in s16 scope > > is set from usual 100s to huge value of pcm->boundary (1.5G), causing a > > very long processing at 100% core load. > > > > The debug around the event looks like this, suddenly meter->now drops down: > > > > s16_update 1: meter->now 2567498, s16->old 2566593, size 905 > > s16_update 1: meter->now 2568401, s16->old 2567498, size 903 > > s16_update 1: meter->now 20786, s16->old 20786, size 0 > > s16_update 1: meter->now 1065, s16->old 20786, size -19721 > > s16_update 1: meter->now 24839, s16->old 24838, size 1 > > s16_update 1: meter->now 701, s16->old 24839, size -24138 > > s16_update 1: meter->now 1253162, s16->old 701, size 1252461 > > s16_update 1: meter->now 1255148, s16->old 1253162, size 1986 > > > > .......... > > > > s16_update 1: meter->now 11136, s16->old 10261, size 875 > > s16_update 1: meter->now 22525, s16->old 22524, size 1 > > s16_update 1: meter->now 963, s16->old 22525, size -21562 > > s16_update 1: meter->now 1270914, s16->old 963, size 1269951 > > s16_update 1: meter->now 1272917, s16->old 1270914, size 2003 > > > > I think the problem is that s16->old is not reset when status.appl_ptr > is zeroed and starts running again. There is a call > > static void s16_reset(snd_pcm_scope_t *scope) > { > snd_pcm_scope_s16_t *s16 = scope->private_data; > snd_pcm_meter_t *meter = s16->pcm->private_data; > s16->old = meter->now; > } > > but I do not know when this method is called and whether the meter->now > is already assigned to the newly zeroed status.appl_ptr. Would adding atomic_add(&meter->reset, 1) in snd_pcm_meter_reset() help? Takashi > > Please at which method should I reset s16->old = 0? > * s16_reset > * s16_enable > * s16_start > * snd_pcm_scope_s16_open > > > Thanks a lot for any help, > > Pavel. >