Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp812720ybm; Wed, 27 May 2020 08:36:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygUi99yUz0muED0KgFn3rIY1uw4VVDDJ6Nx5mkM0bhUyaCEDP2OdK1NyT8nxy8CS+FRZ4D X-Received: by 2002:a50:f0ce:: with SMTP id a14mr24808955edm.131.1590593788145; Wed, 27 May 2020 08:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590593788; cv=none; d=google.com; s=arc-20160816; b=JwbmfrkGqECwJxUz2DwyXveKmpBi825catkd4ter5Hi5/dMHLKxKPyQB8G6NE0uhTk LGkAPOwb1ecrk1+dgZ461N8EU5Yf4Q8TJ0jxf2fnSjLqCbwy7ikOq24OWcOGfPvEelk3 DJc9EyrRtkoCbF1PLKowGyGZ1gcOgm8etWiqHhhDsDTzbpNds4TLdJ1Gx//DVK+HZD24 P52QCr5pMXrSJuQKuxc+NH/i3Zy3kcWcr+We+SpgEOFrBPjOHCxxEZbV/kpmKabV3+/Y efLaDqG5n4n4WQte5xeFRHPzWQVvmbfDCQPQXUVYWp1Ax8KIx49rSYBIdIFmeqbNJATy qCXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=pCH+Sehu6P7XqS4qbiCktbpA1kblie/UDIy1mCh/XtA=; b=vC9+j0d0TTAHSM4BQo/kwQhXGux1N3TYzAR/BO5GJc2yopbGDg651NsMUnisNWGqJu YfyTw5tvcxxRiGcVPBafN/FiTvpOuzNfvyMuSUWT6FB255ja+Pk2c1G0bghpsZwDfrph LTNVIcC7CnwrTzIBQJUNzKhhQNHh5Hksm+9tQ1zHTZ6YSz6PCUVqvQUWfEahY4KWpYm6 DtjLRPX0aPG4wnsNBK0W8DAYax01Vq7LuXEicGEU5DS/hy1OXXv+l6jAz/b1yJFjT5RM dJ1lTNhR+KlBUEnNwX5CILc+gnNsko4JS+dG9Nd4ihYdF+P+4gZ3JGyZfsEUskPkrajx p2ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PZdwrY6L; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o25si2063788ejh.304.2020.05.27.08.35.29; Wed, 27 May 2020 08:36:28 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PZdwrY6L; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725948AbgE0KZk (ORCPT + 99 others); Wed, 27 May 2020 06:25:40 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:52307 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725747AbgE0KZj (ORCPT ); Wed, 27 May 2020 06:25:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590575138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pCH+Sehu6P7XqS4qbiCktbpA1kblie/UDIy1mCh/XtA=; b=PZdwrY6LFBx4DWyMbPaSkE912d3rbRtgtlYuhILyvCb2Gf0h9hTZBPWMmANEro5fG8JvRZ JKvHy5lKt5ndVZibKHYgrWZts99cT9DaMYTTGJOQBx6/INLj6L+ktTIBDF12TkjGx5qMA5 X4xu+/WrmCvIJAtkyaMYwLcNiOqx16U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-GRmnCcb5OGOHh0N_94S4EA-1; Wed, 27 May 2020 06:25:36 -0400 X-MC-Unique: GRmnCcb5OGOHh0N_94S4EA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32B8EEC1B5; Wed, 27 May 2020 10:25:35 +0000 (UTC) Received: from krava (unknown [10.40.195.83]) by smtp.corp.redhat.com (Postfix) with SMTP id 227ED60C05; Wed, 27 May 2020 10:25:33 +0000 (UTC) Date: Wed, 27 May 2020 12:25:33 +0200 From: Jiri Olsa To: Matt Fleming Cc: Jiri Olsa , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] perf ordered_events: Optimise event object reuse Message-ID: <20200527102533.GG350217@krava> References: <20200526135928.946-1-matt@codeblueprint.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200526135928.946-1-matt@codeblueprint.co.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 26, 2020 at 02:59:28PM +0100, Matt Fleming wrote: SNIP > + > +/* > + * Allocate a new event object from the free event cache. > + * > + * Find the first address range in the cache and carve out enough bytes > + * for an ordered_event objects. The object with the lowest address is > + * always returned so that subsequent allocations benefit from > + * contiguous memory accesses (spatial locality). > + */ > +static struct ordered_event *free_event_get_tree(struct ordered_events *oe) > +{ > + struct interval_tree_node *it; > + struct ordered_event *new; > + size_t bytes = sizeof(*new); > + > + it = interval_tree_iter_first(&oe->cache.rb, 0, ULONG_MAX); > + if (!it) > + return NULL; > + > + /* Has the cache memory been exhausted? */ > + assert(cache_region_size(it) >= bytes); > + > + new = (void *)it->start; > + > + if (cache_region_size(it) == bytes) { > + interval_tree_remove(it, &oe->cache.rb); > + free(it); > + } > + > + it->start += bytes; this does not look right.. should this go to else path in above condition? jirka > + return new; > +} > + SNIP