Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp818867rwp; Thu, 13 Jul 2023 01:14:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlHfWvBi3cQsDIJlWLypbgqnP2Ep7FsOVPx750YKqpCNx5S+RpFhQCN3iIjoMIzsVf+W/ppM X-Received: by 2002:a05:6a20:3d8f:b0:12b:e9a0:f015 with SMTP id s15-20020a056a203d8f00b0012be9a0f015mr1004626pzi.17.1689236081073; Thu, 13 Jul 2023 01:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689236081; cv=none; d=google.com; s=arc-20160816; b=WsaOYNvA96yW3PCi2+UKZRznkzyrTdDPYR9nE8GhJgNd7umpJYtUX5PylEgAmxJR7W FbVCS/pecFsQX8L2vv94M5XXRJkQQQu4S2wCwIZei6b3qbkqm2WKDFPnNXVsdsMTpNMQ AmlrDxk5hKgu84oKq1J+50y84hkK2HeVTahpvIMeGn9RH+EdzzKo9ba0UVL2sZNxKuLU Sh/aM7eGtOxQjHjGtDUeADPsgGAPIVSkMgsSW7hEnKgHI9K6fdhYtuYQBCcqHqBRXrYh BaIhlAYeh1C5d98jWjviKSoqmxaNgvwbCueZdlmlmmtC3H4TEF5mTRGvdG5d5qYkXh6N qcCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zQWUSEoOR5t3MEXAfVU6qpzWsgyy+Mooxn06h3Z1zKo=; fh=Z7A+1BnnO2Wy4WuR/H+yDPDd4ZAQG/u3CNanu81cjOw=; b=OUKq2X42PdZaTFlrk1OtJWgyGesjiTbJmZIOFPL1aBWc4CgGJLkWd634k3K3PFc/hG IsM8jPXDl38OsddPU5cKX/h5hxJw+9f8TQwDhMC8h54v6BabStZGZoo3LyM2u7TNvJPp VheUKbb6NkgjYgP3j98nyOmgefLa814bMBk4koBbQ60esNaznRX0cDQyYXGVqOYbL391 MsHys8UuJduP2Jo2cudlOnmHdOttCScmCPLzcNXlY2iFt20dMxKo87ubouWTK0PkHuZT XcJScWM62xOT2qAlIhxw/j85Soz7e7d02sMrrIvVEcxVHkROjJGDXNddYipPENOTNYZ3 boqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AbdHpSx4; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eh12-20020a056a00808c00b00682cba7571fsi4781672pfb.385.2023.07.13.01.14.29; Thu, 13 Jul 2023 01:14:41 -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=@gmail.com header.s=20221208 header.b=AbdHpSx4; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233797AbjGMICY (ORCPT + 99 others); Thu, 13 Jul 2023 04:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233755AbjGMIBu (ORCPT ); Thu, 13 Jul 2023 04:01:50 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E8226A2 for ; Thu, 13 Jul 2023 01:00:27 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fbf9e4c0d5so103566e87.1 for ; Thu, 13 Jul 2023 01:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689235208; x=1691827208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zQWUSEoOR5t3MEXAfVU6qpzWsgyy+Mooxn06h3Z1zKo=; b=AbdHpSx4W0NU1QBnqdMfK5CRrsrCnCDXoNeNtfRok8O6iX1amyWXGG5Mk/QKRKTAwC 9KW+bTz5eZFBTyuq4Y0wxP7KBdIO836HbQ73gkAb493zR4IwTrjk0tsXs3/IELE/H7wm VxkVNCGVeEIaAUwf0aZpMLOCq7J2zB+Pp84scSphSsXA1XTWl2vYk+4Oy++5BFR1ilkD wYDeskynXwOoE17nfa7gMUCT46k8f3zhiWQHJFTEOW9elUY+8yzuowcG3/TY8SJAaaje 3Irjw2wlQ7B04AwJXPzb7gUGC1jcJbNNAMu+TbJt+VGfwjl1cseVeke5MlxYgx6EqwLv FTJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689235208; x=1691827208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zQWUSEoOR5t3MEXAfVU6qpzWsgyy+Mooxn06h3Z1zKo=; b=V1aBRktJzxs4i3S1JlCoLbemhCaYvvnw65WWjYRM8zXfcUJoIy1/vr0O5dyOCA2pak mDoFfVVkIdDPNZmKRxRkBD57a2D2d3T3ir/XciBpZN0iiLHh7h5AuxHk2Y7x0oR8WR+D wSU7UMNq+0XMlANwFQE0H0A4whKfCNDcSXUfAQNNxSBIpi4gaNi2e91ZWV4LO9744IxK MN4ZiDGYHZEAYx7aMumg5PfHIENFm+wKVTY+x6pyoRWD62eguvft9ROl4qSniP9FrrJg 2d8eD0nTmM+6r0MofD7gBiipJ1Vris+6jQKUbqOPyikG8ykjox7j4tVJO4p74I+f1FSP oE9w== X-Gm-Message-State: ABy/qLaugGpj6jkTjOWFQ5HTOrHXiP8LGETfYzS2gLussgoRzu9nQkhD S4lCdda5MRB0gH4ewtXDuzQ= X-Received: by 2002:ac2:4833:0:b0:4fb:8eac:8571 with SMTP id 19-20020ac24833000000b004fb8eac8571mr491482lft.0.1689235208117; Thu, 13 Jul 2023 01:00:08 -0700 (PDT) Received: from ivan-HLYL-WXX9.. ([178.160.196.94]) by smtp.gmail.com with ESMTPSA id q8-20020ac25288000000b004fb8c0f247fsm1011385lfm.129.2023.07.13.01.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:00:07 -0700 (PDT) From: Ivan Orlov To: perex@perex.cz, tiwai@suse.com Cc: Ivan Orlov , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] ALSA: pcmtest: minor optimizations Date: Thu, 13 Jul 2023 11:59:53 +0400 Message-Id: <20230713075953.13692-2-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713075953.13692-1-ivan.orlov0322@gmail.com> References: <20230713075953.13692-1-ivan.orlov0322@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,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 Decrease the buffer filling overhead with conditional remainder calculation in the 'inc_buf_pos' inline function. Fix the driver to use already defined variables where it is possible in 'check_buf_block_ni' and 'fill_block_pattern_n' functions. Signed-off-by: Ivan Orlov --- V1 -> V2: - Split changes in the patch into two different patches sound/drivers/pcmtest.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index e74c523e49eb..08e14b5eb772 100644 --- a/sound/drivers/pcmtest.c +++ b/sound/drivers/pcmtest.c @@ -144,7 +144,8 @@ static inline void inc_buf_pos(struct pcmtst_buf_iter *v_iter, size_t by, size_t { v_iter->total_bytes += by; v_iter->buf_pos += by; - v_iter->buf_pos %= bytes; + if (v_iter->buf_pos >= bytes) + v_iter->buf_pos %= bytes; } /* @@ -200,10 +201,10 @@ static void check_buf_block_ni(struct pcmtst_buf_iter *v_iter, struct snd_pcm_ru u8 current_byte; for (i = 0; i < v_iter->b_rw; i++) { - current_byte = runtime->dma_area[buf_pos_n(v_iter, channels, i % channels)]; + ch_num = i % channels; + current_byte = runtime->dma_area[buf_pos_n(v_iter, channels, ch_num)]; if (!current_byte) break; - ch_num = i % channels; if (current_byte != patt_bufs[ch_num].buf[(v_iter->total_bytes / channels) % patt_bufs[ch_num].len]) { v_iter->is_buf_corrupted = true; @@ -243,7 +244,7 @@ static void fill_block_pattern_n(struct pcmtst_buf_iter *v_iter, struct snd_pcm_ for (i = 0; i < v_iter->b_rw; i++) { ch_num = i % channels; - runtime->dma_area[buf_pos_n(v_iter, channels, i % channels)] = + runtime->dma_area[buf_pos_n(v_iter, channels, ch_num)] = patt_bufs[ch_num].buf[(v_iter->total_bytes / channels) % patt_bufs[ch_num].len]; inc_buf_pos(v_iter, 1, runtime->dma_bytes); -- 2.34.1