Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp140937pxb; Mon, 18 Oct 2021 22:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxsgTAsy1qngkZqWNQaNiFoJ1XTkYUQ3DVY6bHJaSUc11x+IwT9k9LbPfTq9ftSssn0n4g X-Received: by 2002:a17:907:7691:: with SMTP id jv17mr33965690ejc.378.1634623075614; Mon, 18 Oct 2021 22:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634623075; cv=none; d=google.com; s=arc-20160816; b=BojyMiztrCjv252bQyGO5EoCHDb9PoD0VYVFb4jweFSGaUpKRF5w5L5m1G0+ZsfOlW mNQFyLKS2urtYZsCXV+UyzlI2i+tQGvgpMvOz1iXH3imwwRkQVRGHN+w/QNbtDCAhrE/ qhJvtIm+nJc5W8MDnXtYATI3AlIEc+zkpkudjxuvLtnGK1BgdBgnLHFZ60Q2+kTFcoYF usQG2wFrbErI2LxJjdX2Yw74uHD4Rckp1uciz1kt+JWa1mNd7nW9HgBUMsFNSyNmH0tY YOMO6OXLg5/xsfcJ0dt/YoBG7PwLgeN/MYJe6QammVDzDemwp49h9QxakY76azXzCYDH FWlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=66H13UA6ci/CiXwJ2PZOC4ha88zz1JB+smlEker9FJE=; b=kx2a6sTBRyH+3qQ+gVdW8EU8VSO9227EA9dr+slUWFT9H7XxgcNQoOBS3nABq6oXj5 yMrxgZf9EgO/rAL/prVK7hBFJzK2Q7965QKyYYv1jYtL37TYLZAJ1qlxsxUKwi4mnCH/ 83ThsdPxfLTeaHKOEoXCdzK5lOAUbJ5AzhAPsTzXOYdiyzX24cON28D3kF0043Lqgcgu oEtPIhDwihISG4lfwG7QP9ykvx/k5nwYban97gNu8fMByyFKtDh5r+OoSAQXwZHu+m8w jiEjGwkyFYdg6hK7X/xAmiX2Q2oDBGF1URaCz8wHI/6h+ZfI/jRuQS86lYWYS4/T2hz3 Gh4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb41si11323618ejc.670.2021.10.18.22.57.31; Mon, 18 Oct 2021 22:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233392AbhJSF5Z (ORCPT + 99 others); Tue, 19 Oct 2021 01:57:25 -0400 Received: from foss.arm.com ([217.140.110.172]:44698 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbhJSF5U (ORCPT ); Tue, 19 Oct 2021 01:57:20 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 96E3E2F; Mon, 18 Oct 2021 22:55:07 -0700 (PDT) Received: from [10.163.74.241] (unknown [10.163.74.241]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 572E93F73D; Mon, 18 Oct 2021 22:55:04 -0700 (PDT) Subject: Re: [PATCH v5 12/15] coresight: trbe: Make sure we have enough space To: Suzuki K Poulose , will@kernel.org, mathieu.poirier@linaro.org Cc: catalin.marinas@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, maz@kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20211014223125.2605031-1-suzuki.poulose@arm.com> <20211014223125.2605031-13-suzuki.poulose@arm.com> From: Anshuman Khandual Message-ID: <2363663b-72b4-e249-49d1-b036866fc4fe@arm.com> Date: Tue, 19 Oct 2021 11:25:03 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20211014223125.2605031-13-suzuki.poulose@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/15/21 4:01 AM, Suzuki K Poulose wrote: > The TRBE driver makes sure that there is enough space for a meaningful > run, otherwise pads the given space and restarts the offset calculation > once. But there is no guarantee that we may find space or hit "no space". > Make sure that we repeat the step until, either : > - We have the minimum space > OR > - There is NO space at all. > > Cc: Anshuman Khandual > Cc: Mathieu Poirier > Cc: Mike Leach > Cc: Leo Yan > Reviewed-by: Mathieu Poirier > Signed-off-by: Suzuki K Poulose Reviewed-by: Anshuman Khandual > --- > drivers/hwtracing/coresight/coresight-trbe.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c > index 4a50309a892d..5fb9f49eab33 100644 > --- a/drivers/hwtracing/coresight/coresight-trbe.c > +++ b/drivers/hwtracing/coresight/coresight-trbe.c > @@ -477,10 +477,14 @@ static unsigned long trbe_normal_offset(struct perf_output_handle *handle) > * If the head is too close to the limit and we don't > * have space for a meaningful run, we rather pad it > * and start fresh. > + * > + * We might have to do this more than once to make sure > + * we have enough required space. > */ > - if (limit && ((limit - head) < trbe_min_trace_buf_size(handle))) { > + while (limit && ((limit - head) < trbe_min_trace_buf_size(handle))) { > trbe_pad_buf(handle, limit - head); > limit = __trbe_normal_offset(handle); > + head = PERF_IDX2OFF(handle->head, buf); > } > return limit; > } >