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=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham 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 16F94C4360F for ; Mon, 25 Mar 2019 21:59:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C447620645 for ; Mon, 25 Mar 2019 21:59:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="A9Ky2hCx"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="s5KZY8ly" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C447620645 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=OYSYs6nQYPUO59Eb6z44YJrEwin54k/rFxtFr68BYkk=; b=A9Ky2hCxMS+nwAQ+VsPsuHAOVT OyviU2kFL6O8wBjdECyw8KnYLzLbGMZ7MBZxWnmd46TgJ8XYRi5CiGXbQO4L59225HNEAcd/Uq69B ShUlECjiKKhah4mHT2FT9LxTseH7SCs/LgttC2mG/kJMuYNFLPE+r3IaMmRiNRSWdnjj6oS4Gtope BcvvYqP0o+Fapkg3U46M3FsS9hCuwv+DzeASIlEYFwrIzBAMUkLl/eWkK1sQlRhsVPt7TTZOooOpq aMwVEMDJNMpgUG0mBj+ILIWtHqHOM5nBokCp4c39sxZWh68AwrkM7LUBOHXJsUzvLc+MLKkCHWlWq wZs8GU9g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8XcF-0006S2-5V; Mon, 25 Mar 2019 21:58:47 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8XaN-0003sN-AW for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2019 21:56:59 +0000 Received: by mail-pf1-x444.google.com with SMTP id 9so7046973pfj.13 for ; Mon, 25 Mar 2019 14:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mh7Wb1qKFF0hhvZ5dVf5oYM0kEaSjUe3jeowpeQGKzQ=; b=s5KZY8lyP1p5ip+EYvf0eLzP2XHiZj94t0ngPEJMi3Ar9ZdiYNQYBImMAF5LV5bhIj S+hrN0Ua3CyE9cbQY2u2QBw7RiKza1HCT3iuJK78fhKDD9yqY6TNn5PiRQpljISYb14k P/e3QFgK+b/cxv1+CiuwWtoHUngnWnnlV/O1BwRBb0bHWAUqH0NjOsHREf2nmbW2bDoF VEQqt9I6oY9TTLN+umy37TW8m+3yNzueV2m4c6Xlokwi8/W/Bf8Z9w3xRg8dPS6HmAEQ y/vfjEeXCWfh4uyarIrptzUW/ASLeNsh12Dab/PRkGDrNxvel5GDK4wbsceIzfQyD6Mk rCrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mh7Wb1qKFF0hhvZ5dVf5oYM0kEaSjUe3jeowpeQGKzQ=; b=Vs7Dyw8CK10bqzvY5fZh2i8EK/KBkF5rQ/yWeyRNvP0eaT94sVkrzJjqY7hRWkhW+X Dr0PgtHiWaQosknNI6TwZCHuyoFC+f6PydbCyNty6F5cZg7wWt5Z6C3S1qwxvZoiGx3y NVH0gS2cQT6m1jK3uaJrrNJ79KSH3aPEbPATun3CX3eeVuWrcS1vJ1V1EfHW9rtlZ+9g HfeDIgHifNMqgIR8884D/43UyXCz3KC0d6P+R1vS9CzH7AeKJRHdsy1M1YDUFe8wKkKC qgC6LwqgP1qaGaITF6uwllkF2p32aCNNHQ3oAGTfuepaJPrrSWEmsokoEv72lswMP+Xv c8Nw== X-Gm-Message-State: APjAAAUQ9flNA1XNq9DPHu3lPFZBD8K6I/dBaJnV5yRTyiKUVit6Scuq 1wGO1gh94N6Swl4bvrdMTZd/BPazs4A= X-Google-Smtp-Source: APXvYqy/wUUZeCq0dk9/Rv0Z4FvwDiyfCiqm9XgdrXwBFchEsaAC8AAtYRl89bpFg6yS0JAafO9s8w== X-Received: by 2002:aa7:8c84:: with SMTP id p4mr12858780pfd.164.1553551008607; Mon, 25 Mar 2019 14:56:48 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j20sm30645631pfi.27.2019.03.25.14.56.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2019 14:56:48 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 11/16] coresight: tmc-etr: Refactor function tmc_etr_setup_perf_buf() Date: Mon, 25 Mar 2019 15:56:27 -0600 Message-Id: <20190325215632.17013-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190325215632.17013-1-mathieu.poirier@linaro.org> References: <20190325215632.17013-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190325_145651_879589_6AB772CC X-CRM114-Status: GOOD ( 14.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, peterz@infradead.org, mike.leach@arm.com, leo.yan@linaro.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactoring function tmc_etr_setup_perf_buf() so that it only deals with the high level etr_perf_buffer, and leaving the allocation of the backend buffer (i.e etr_buf) to another function. That way the backend buffer allocation function can decide if it wants to reuse an existing buffer (CPU-wide trace scenarios) or simply create a new one. Signed-off-by: Mathieu Poirier --- .../hwtracing/coresight/coresight-tmc-etr.c | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 6e2c2aa130d5..79fee9341446 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1159,25 +1159,13 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev) return ret; } -/* - * tmc_etr_setup_perf_buf: Allocate ETR buffer for use by perf. - * The size of the hardware buffer is dependent on the size configured - * via sysfs and the perf ring buffer size. We prefer to allocate the - * largest possible size, scaling down the size by half until it - * reaches a minimum limit (1M), beyond which we give up. - */ -static struct etr_perf_buffer * -tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages, - void **pages, bool snapshot) +static struct etr_buf * +tmc_etr_get_etr_buf(struct tmc_drvdata *drvdata, int node, + int nr_pages, void **pages) { struct etr_buf *etr_buf; - struct etr_perf_buffer *etr_perf; unsigned long size; - etr_perf = kzalloc_node(sizeof(*etr_perf), GFP_KERNEL, node); - if (!etr_perf) - return ERR_PTR(-ENOMEM); - /* * Try to match the perf ring buffer size if it is larger * than the size requested via sysfs. @@ -1201,6 +1189,34 @@ tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, int nr_pages, size /= 2; } while (size >= TMC_ETR_PERF_MIN_BUF_SIZE); + return ERR_PTR(-ENOMEM); + +done: + return etr_buf; +} + +/* + * tmc_etr_setup_perf_buf: Allocate ETR buffer for use by perf. + * The size of the hardware buffer is dependent on the size configured + * via sysfs and the perf ring buffer size. We prefer to allocate the + * largest possible size, scaling down the size by half until it + * reaches a minimum limit (1M), beyond which we give up. + */ +static struct etr_perf_buffer * +tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, int node, + int nr_pages, void **pages, bool snapshot) +{ + struct etr_buf *etr_buf; + struct etr_perf_buffer *etr_perf; + + etr_perf = kzalloc_node(sizeof(*etr_perf), GFP_KERNEL, node); + if (!etr_perf) + return ERR_PTR(-ENOMEM); + + etr_buf = tmc_etr_get_etr_buf(drvdata, node, nr_pages, pages); + if (!IS_ERR(etr_buf)) + goto done; + kfree(etr_perf); return ERR_PTR(-ENOMEM); -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel