Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp444986rdf; Fri, 3 Nov 2023 05:38:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCimoJSRvxc2WX28erdVnbhUcvxPLwJflhIEWzyQ/854dcXYLoJM0RGHmfMmlyOM4l+VO3 X-Received: by 2002:a05:6358:5e0c:b0:168:e898:fb7d with SMTP id q12-20020a0563585e0c00b00168e898fb7dmr18261514rwn.28.1699015104653; Fri, 03 Nov 2023 05:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699015104; cv=none; d=google.com; s=arc-20160816; b=Am5JhN3SDlNzD1utw0TMMqzKv/5qtb3ZLtmzyt4L3ISKgO8yzGXve6mdpCivZ0SrfV gGDJAtoh2CmrPedVZt1ygCxSJ/P/6t1aAlm8NNXaHVPvbivcir1N8kXHYL0XE/A45PE2 ccKNygVByBv6bz+XqrRzK1CZtDA4pt13I32wCrpPyxEQerrQO5xftjz2nXqrJP8kCjBn NvDjp6aAUpcdK8omChYkfpts6tOlRE+u7wiwCy0SfJGj1bY4t7+Sy3Fbf5ShW1WsVm2n 9HkAqv9yYp84Vd82XyIsXpxpLYYXxNJyiB+UjciM7icfKYnKJZYNFR6pRlPgN7v14CBY 2RoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=FbOdcT3r22Shg0jXhPNX4VE9G2kLj20NGnovJRJb6M8=; fh=+WCQxZuxbB73exan2cPxyWk/PwfClOHE6eTXh6RvP7E=; b=VIStfex2y4RzuEo5CpNAHr8Mw7yyYRGEQ6PQWQHZBkxls6u3NVS3/0CZf6w8I1mVQ7 FUVDrp46m9+B3/9tDrs/qsMGgPu0cO8rkfHZfOcpIdgLJlecRYJ6Hxy3qlpG02PEetfu EJY/SgtinLV81IRvs4C/qDSJwFaB5JkL5xJgpx02PioFa3D+5FFRX+ub77vYfuJDGiwY wj4L1LalFL7Q8lEt3q5zFq1+fiAeFzjNFPieyf+HWi8rt6Nlx6uwUmZiD1RupsvtTbL/ qzoCcu6mvsJYwLvwkNCz/pz3OX5ytYFDi9MuhuGLpKbN4wpUJlCzB0QG4mv6XdLO6Ew9 vEHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XqAZGt5o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u185-20020a6385c2000000b005b982b6a01fsi1382610pgd.39.2023.11.03.05.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XqAZGt5o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1B1F0829768C; Fri, 3 Nov 2023 05:38:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbjKCMiN (ORCPT + 99 others); Fri, 3 Nov 2023 08:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjKCMiM (ORCPT ); Fri, 3 Nov 2023 08:38:12 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BDA583 for ; Fri, 3 Nov 2023 05:38:10 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9d8d3b65a67so291832966b.2 for ; Fri, 03 Nov 2023 05:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699015088; x=1699619888; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=FbOdcT3r22Shg0jXhPNX4VE9G2kLj20NGnovJRJb6M8=; b=XqAZGt5oP9uTcZpNMtnNkoeRsxaJ8mi6U3/FMQgEz95FbwwPtVljMBLm/wcBmrfiee h013q66VZ67rzXgop5Dy1VPz1baRsXeqM2PZnkkKkiiEJxxcsPtMm4Xn+32l0qYX+mjs LsPf25gU6djqZX63yIqWm+pU0s9eIwsG3p7Sb7Lx1E8T0PlCs0X0ytNDmRtr7G1EavQg qSf1gjgakssGxeGo8KkyuY/1LtWDZCVkmF+joxEtYRDsnCQb8Iaf8Zc54xt7WNMguTP0 GKxZL9OJA3e8/Uvli614KlNuK5AM7G3JN2DAXyLsO5Iw8vTi/UqTMTtp/b34+6iWKZ3X hRig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699015088; x=1699619888; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FbOdcT3r22Shg0jXhPNX4VE9G2kLj20NGnovJRJb6M8=; b=vOYVEQmN0qTojlgrdeERAtUnLHNO0y4HFgCpxa85XCkjkuo8SsiXgjk+2i5uWnNFvr oHnyM6bBFpOmBXHb8ypnBoz+5SwNJyDTVy4I2Eed+nyXVIAXMtlbv7foy7363DP+QKBT mqxX8k2AADKXfbhdqEa+UMowOadIRKWnK+E/cSzwUXAdGPpJ0PSU7EbOpu1LGm1EhLoa O48YbaUzWr5xSXQUtvJ20/uSNk80VJAUdTs6tIwjRqFkM7QB70ksHHsDIm+quxICYDrc lT0zg0gdgKhCoAb/tUgMEJHYXe46AdZ+rbZfLtXGma8490DHoFPLWIKOgVIYiXjLG2q+ PlOg== X-Gm-Message-State: AOJu0YzaO6knI+ADoPLNHdhBVNRga8/T9/8ewn8CJ3lmGdvJrQloWrF+ PaZhBrMSZwvaK0uyXwvduZM= X-Received: by 2002:a17:906:db01:b0:9d5:9ff5:ce with SMTP id xj1-20020a170906db0100b009d59ff500cemr6210521ejb.34.1699015088316; Fri, 03 Nov 2023 05:38:08 -0700 (PDT) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id g4-20020a05600c310400b004068e09a70bsm2353829wmo.31.2023.11.03.05.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:38:07 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Fri, 3 Nov 2023 13:38:05 +0100 To: Peter Zijlstra Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com Subject: Re: [PATCH 01/13] perf: Simplify perf_event_alloc() error path Message-ID: References: <20231102150919.719936610@infradead.org> <20231102152017.847792675@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231102152017.847792675@infradead.org> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 05:38:22 -0700 (PDT) On Thu, Nov 02, 2023 at 04:09:20PM +0100, Peter Zijlstra wrote: SNIP > @@ -11936,24 +11957,24 @@ perf_event_alloc(struct perf_event_attr > */ > if (pmu->task_ctx_nr == perf_invalid_context && (task || cgroup_fd != -1)) { > err = -EINVAL; > - goto err_pmu; > + goto err; > } > > if (event->attr.aux_output && > !(pmu->capabilities & PERF_PMU_CAP_AUX_OUTPUT)) { > err = -EOPNOTSUPP; > - goto err_pmu; > + goto err; > } > > if (cgroup_fd != -1) { > err = perf_cgroup_connect(cgroup_fd, event, attr, group_leader); > if (err) > - goto err_pmu; > + goto err; > } > > err = exclusive_event_init(event); > if (err) > - goto err_pmu; > + goto err; > > if (has_addr_filter(event)) { > event->addr_filter_ranges = kcalloc(pmu->nr_addr_filters, > @@ -11961,7 +11982,7 @@ perf_event_alloc(struct perf_event_attr > GFP_KERNEL); > if (!event->addr_filter_ranges) { > err = -ENOMEM; > - goto err_per_task; > + goto err; > } > > /* > @@ -11986,41 +12007,21 @@ perf_event_alloc(struct perf_event_attr > if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { > err = get_callchain_buffers(attr->sample_max_stack); > if (err) > - goto err_addr_filters; > + goto err; > } > } > > err = security_perf_event_alloc(event); > if (err) > - goto err_callchain_buffer; > + goto err; > > /* symmetric to unaccount_event() in _free_event() */ > account_event(event); > > return event; > > -err_callchain_buffer: > - if (!event->parent) { > - if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) > - put_callchain_buffers(); > - } hum, so this is now called all the time via __free_event, but it should be called only if we passed get_callchain_buffers call.. this could screw up nr_callchain_events number eventually no? jirka > -err_addr_filters: > - kfree(event->addr_filter_ranges); > - > -err_per_task: > - exclusive_event_destroy(event); > - > -err_pmu: > - if (is_cgroup_event(event)) > - perf_detach_cgroup(event); > - if (event->destroy) > - event->destroy(event); > - module_put(pmu->module); > -err_ns: > - if (event->hw.target) > - put_task_struct(event->hw.target); > - call_rcu(&event->rcu_head, free_event_rcu); > - > +err: > + __free_event(event); > return ERR_PTR(err); > } > > >