Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1467619ybx; Thu, 31 Oct 2019 11:01:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqypkxq6PbVx20UA3HiwiRh8z32Yq+N93tWqE9v+EuacxbSzxgoTjjnAXu7OzNe1Japy9SpJ X-Received: by 2002:a17:906:8417:: with SMTP id n23mr5415576ejx.175.1572544860940; Thu, 31 Oct 2019 11:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572544860; cv=none; d=google.com; s=arc-20160816; b=hoX5kVnQQgFNT3L0ucVxIOtCgCKha6528g/hVvb8vfU2DUgSTz4DWJ4DdpdNLCmdv0 hf3HYY6XJKLLg06A+c9+ZRgCdBvd4gno9eVO1ZTJ3Ioo8QYi76I6mwP0ngE9xFopAoCA 9ru6Y9Vf/4/tsdORWDfpaD/3+p/GL/NSy/FBXKp7cui0hNvv2EiuDiHKH5+Ypy+CSu8Q CDgGZesUgakBSPqpy9C7aLyP2f+L115LJaF49kOvjsF5RYo1IBmjs0tmmkgMRuz/wLHB SuCw8zkWIbeVp0y1Z1TCOJYttsxra/MfCjI5+0mlkMDIs8BplLP8k7XAp+HINkIjjiS6 2iog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:date:from :dkim-signature; bh=sWokwVhyBdp2QZIlCKCrU1UgOSXDRZkXLq1Z+cZh/9o=; b=sTDxIoXURiX2vWLd0Lysc42zPud/M46HFMHmIp1X5DzLJeJTVLbQXzo+unpX8YJo5G DMN1e7XUkoxrqoLfViF8W0FfD4nMMB634YOa1Q5AFkr0ETc1uoDbGSojwgEZ9Tc2nl3W n4TTK59Sem19SNG2W3YUEDJnlRj9gWsZzd2Y9tmnvwXmtlbrEvYevYcqXIJB2IqFUvPc nxVoRY+ugzFOz1t4YVUHmFhFvQFrvdDYUSmGrc5Ddkl+CCEfGTIYYosACrj8x+iF1r9p i2cWLMiewjX7cAfclLXUVRlDGKM2ff110GfWkd3AQP+6rdVG7OoFYzro3SAumy7ZojLA eHxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OD0iyUkN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h5si5203993edj.25.2019.10.31.11.00.36; Thu, 31 Oct 2019 11:01:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OD0iyUkN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729149AbfJaR7J (ORCPT + 99 others); Thu, 31 Oct 2019 13:59:09 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:43649 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729130AbfJaR7J (ORCPT ); Thu, 31 Oct 2019 13:59:09 -0400 Received: by mail-qt1-f193.google.com with SMTP id c26so9705608qtj.10 for ; Thu, 31 Oct 2019 10:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:mime-version:content-disposition :in-reply-to:user-agent; bh=sWokwVhyBdp2QZIlCKCrU1UgOSXDRZkXLq1Z+cZh/9o=; b=OD0iyUkND88c/Dsb6v7RwGZC1Ei0pIviY3aMxTUV1K+Qh0lhujW7/36dHm+tbtuF6z 51O7laPdBI3EmCMkusK1hnt8sw/JKoR791C+ApIYrx6g7MOiquQqXJO1fmKm9q6u7xM6 MB2yLh3VF4VwGOyrFGvNyG7Du3SWZ/j2FRe6KnLBc7t1ynu46mrhFASXLespidNuCctW FyBb94uHst+VdRM9DrAfurrK5gaeArvQWY2mQckj9YAQ0rMwBDtwUx8PWxlBSwC0SYQC xnv3/p34A9IZdgDXrqvLw8mFvw9kGWYpHoAEM2JkFWKsEC9h3bG/C6ACsRBTxp3RzRnT g13A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:mime-version :content-disposition:in-reply-to:user-agent; bh=sWokwVhyBdp2QZIlCKCrU1UgOSXDRZkXLq1Z+cZh/9o=; b=Au3+qoA9dKt53gWeA2Y5ejdApCjj9xgit5aRYcTwClJNQGmr+43CjpAHB6Tszv1Vze 9pbxpdZ3/Ym7KesgKoVXddM3jocPJIyTdxkcAONlgELBH1h6Yce6Ap48Yr9yArW17VCu tJI6v9aY2DsGUY02ro1Kh8o+04xqD3ls9/4CyHCV7kLKakfbxfspevssUJ2Y0xB7RJyL VythK7aOozhZ8kTuWwhEv76Qpt5zHluge43iEXoG9VbTwRJYlV8tLnKe15qIU5NQce6l H1pHb66WJQ/LnTWhQdyEFdLEQxhtD5yiZ2n2Q3VxvlsjwgO4+Ww9FJhRxFz0+NT6UTr/ Xkig== X-Gm-Message-State: APjAAAVHIbfxD5icvq90d430y5BZQZz8YmXGtm9v2uV1DxNg/mvzJ5BZ e8vYD6oJbAmhnEmMVY5w6No= X-Received: by 2002:ac8:141a:: with SMTP id k26mr6819012qtj.372.1572544748142; Thu, 31 Oct 2019 10:59:08 -0700 (PDT) Received: from quaco.ghostprotocols.net (187-26-106-94.3g.claro.net.br. [187.26.106.94]) by smtp.gmail.com with ESMTPSA id a66sm2164371qkd.34.2019.10.31.10.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 10:59:06 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id EBF38408F8; Thu, 31 Oct 2019 14:59:02 -0300 (-03) Date: Thu, 31 Oct 2019 14:59:02 -0300 To: Steve MacLean Cc: Steve MacLean , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Stephane Eranian , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] perf inject --jit: Remove //anon mmap events Message-ID: <20191031175902.GB15593@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1572483912-111747-1-git-send-email-steve.maclean@linux.microsoft.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Oct 30, 2019 at 06:05:12PM -0700, Steve MacLean escreveu: > From: Steve MacLean > @@ -749,6 +750,34 @@ static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr) > return 0; > } > > +static void jit_add_pid(struct machine *machine, pid_t pid) > +{ > + struct thread *thread = machine__findnew_thread(machine, pid, pid); > + > + if (!thread) > + { > + pr_err("jit_add_pid() thread not found\n"); > + > + return; > + } Can you please follow the coding style used in tools/? Its mostly the same as for the kernel sources. I.e. above you need to have it as: if (!thread) { pr_err("jit_add_pid() thread not found\n"); return; } There also consider using __funct__ and showing the pid that wasn't found. > + > + thread->priv = (void *) 1; No space after the cast. > +} > + > +static bool jit_has_pid(struct machine *machine, pid_t pid) > +{ > + struct thread *thread = machine__findnew_thread(machine, pid, pid); > + > + if (!thread) > + { > + pr_err("jit_has_pid() thread not found\n"); > + > + return 0; > + } > + > + return (bool) thread->priv; Same style problems and the only way for machine__findnew_thread() to fail is if the system is under severe memory exhaustion, what you probably want to use here is machine__find_thread(), that will fail if the pid isn't found, the findnew methods, in the machine class or elsewhere will return an existing thread _or_ create and insert it, then return the newly added/inserted object. > +} > + > int > jit_process(struct perf_session *session, > struct perf_data *output, > @@ -765,7 +794,15 @@ static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr) > * first, detect marker mmap (i.e., the jitdump mmap) > */ > if (jit_detect(filename, pid)) > + { if () { > + /* > + * Strip //anon* mmaps if we processed a jitdump for this pid > + */ // can be used, not strictly required tho, the way you used is acceptable. > + if (jit_has_pid(machine, pid) && (strncmp(filename, "//anon", 6) == 0)) > + return 1; > + > return 0; > + } > > memset(&jd, 0, sizeof(jd)); > > @@ -784,6 +821,7 @@ static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr) > > ret = jit_inject(&jd, filename); > if (!ret) { > + jit_add_pid(machine, pid); > *nbytes = jd.bytes_written; > ret = 1; > }