From patchwork Fri Jan 5 22:31:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Smythies X-Patchwork-Id: 10147159 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D63E60153 for ; Fri, 5 Jan 2018 22:31:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48D1128958 for ; Fri, 5 Jan 2018 22:31:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B9F82895F; Fri, 5 Jan 2018 22:31:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E141A28958 for ; Fri, 5 Jan 2018 22:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753276AbeAEWbn (ORCPT ); Fri, 5 Jan 2018 17:31:43 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36542 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753271AbeAEWbm (ORCPT ); Fri, 5 Jan 2018 17:31:42 -0500 Received: by mail-pf0-f195.google.com with SMTP id 23so68813pfp.3; Fri, 05 Jan 2018 14:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Ev7bdy3Qp0U6hRhtkfuyOu7g/XX1+Z4EiyS9ab/TYGM=; b=H2SkbbIwJJZPFKE0+17ABPZiYGoUuXkh8vSZ6pHbiR7qmza5Ft5bDTMkdLi+r+Q74J L+DmS8BKUa6lHEpg1sYiEIAjJEjP9eQrQ91IsktIGZvluzegw5w+NUeiorHU06V8a8h0 JM92MuuvquEaudljf5FXy08I4ge9npS/POpwDIabsoYfzk5t7zAri/IPDWxbb9VIGdvp KKqz6+cmda4Veq/hBK2hkoZ3xuG39feIM7jqfjKEbz05tJ34Y1iAhRH0I300x8wZ+IUo mAz9OvZro8jNmRJbLVcBYU1dDncb0M9I2YNMqrqjyc1U6ufni9sb9s7jdOC6uzxwR5AD qyEw== 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; bh=Ev7bdy3Qp0U6hRhtkfuyOu7g/XX1+Z4EiyS9ab/TYGM=; b=G/sJcp48bzGsg2lcUxNGusnHWl1iQXZKoHBLYHnLDqWGT+CL0zephlEF27JX3KFivJ PGtsCeB6pgiL9assuXUktO2Z3PHVM/JlxHM1fCFscaq6IFuMHfFhI5cMOm7Bl5QFmkjq nhjQD8nqiTycATa2sUAmLYepxoGlKBfrpBag3askD3dCvUiYoRpspMLztmB2k58vnSpb NQdR51LIowFiT5euEfAMg/9pSbYLBwe48IOgIYBjaI1VpzzA6uixJaytEe8BaluZtPlM PAA2ue7LghnY+2AFLNwoDmRY0pkdoBgTAVqOmlVH8SelI6u+QcltLGP31mGMATz868EE 9Elg== X-Gm-Message-State: AKGB3mIuW/Ukbr58KIQgq92WFDmvS+jmXatk9sOEEp7YgAQG8IAw3tSJ LQHGecg0Xn4b1ysKsiwURSI= X-Google-Smtp-Source: ACJfBovM4nhYpSb2B9fZq/SREKEv3oZ6sFEUFQVHUvZ20q9eyP99EqDsNDB6Z2aFhpFD45DiLQKuCA== X-Received: by 10.99.65.7 with SMTP id o7mr3791131pga.238.1515191502250; Fri, 05 Jan 2018 14:31:42 -0800 (PST) Received: from s15.smythies.com (mail.smythies.com. [173.180.45.4]) by smtp.gmail.com with ESMTPSA id w84sm16250165pfk.16.2018.01.05.14.31.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 14:31:41 -0800 (PST) From: Doug Smythies X-Google-Original-From: Doug Smythies To: srinivas.pandruvada@linux.intel.com Cc: dsmythies@telus.net, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH] tools/power/x86/intel_pstate_tracer: Free the trace buffer memory Date: Fri, 5 Jan 2018 14:31:16 -0800 Message-Id: <1515191476-3424-1-git-send-email-dsmythies@telus.net> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The trace buffer memory should be, mostly, freed after the buffer has been output. This patch is required before a future patch that will allow the user to override the default, and specify the trace buffer memory allocation as a command line option. Signed-off-by: Doug Smythies Acked-by: Srinivas Pandruvada --- .../power/x86/intel_pstate_tracer/intel_pstate_tracer.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py index 0b24dd9..29f50d4 100755 --- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py +++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py @@ -411,6 +411,16 @@ def set_trace_buffer_size(): print('IO error setting trace buffer size ') quit() +def free_trace_buffer(): + """ Free the trace buffer memory """ + + try: + open('/sys/kernel/debug/tracing/buffer_size_kb' + , 'w').write("1") + except: + print('IO error setting trace buffer size ') + quit() + def read_trace_data(filename): """ Read and parse trace data """ @@ -583,4 +593,9 @@ for root, dirs, files in os.walk('.'): for f in files: fix_ownership(f) +clear_trace_file() +# Free the memory +if interval: + free_trace_buffer() + os.chdir('../../')