Linux-Trace-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 05/15] kernel-shark: Introduce libkshark-hash
Date: Tue, 6 Oct 2020 17:02:22 -0400
Message-ID: <20201006170222.0093ab92@gandalf.local.home> (raw)
In-Reply-To: <20200929134123.178688-6-y.karadz@gmail.com>

On Tue, 29 Sep 2020 16:41:13 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> +/**
> + * Create new hash table of Ids.
> + */
> +struct kshark_hash_id *kshark_hash_id_alloc(size_t n_bits)
> +{
> +	struct kshark_hash_id *hash;
> +	size_t size;
> +
> +	hash = calloc(1, sizeof(*hash));
> +	assert(hash);

For failed memory, is the general plan to just crash? (assert) or return
NULL?

> +
> +	hash->n_bits = n_bits;
> +	hash->count = 0;
> +
> +	size = hash_size(hash);
> +	hash->hash = calloc(size, sizeof(*hash->hash));

In either case, this needs to be checked too.

> +
> +	return hash;
> +}
> +
> +/** Free the hash table of Ids. */
> +void kshark_hash_id_free(struct kshark_hash_id *hash)
> +{
> +	if (!hash)
> +		return;
> +
> +	kshark_hash_id_clear(hash);
> +	free(hash->hash);
> +	free(hash);
> +}
> +

> diff --git a/src/libkshark.h b/src/libkshark.h
> index 9eecc2d..57bd5e5 100644
> --- a/src/libkshark.h
> +++ b/src/libkshark.h
> @@ -33,6 +33,7 @@ extern "C" {
>  // KernelShark
>  #include "libkshark-plugin.h"
>  
> +

Extra white space.

>  /**
>   * Kernel Shark entry contains all information from one trace record needed
>   * in order to  visualize the time-series of trace records. The part of the
> @@ -72,6 +73,52 @@ struct kshark_entry {
>  	int64_t		ts;
>  };
>  
> +/** Size of the task'c hash table in terms of bits being used by the key. */

 "task'c" ?

-- Steve


> +#define KS_TASK_HASH_NBITS	16
> +
> +/** Size of the hash table of Ids in terms of bits being used by the key. */
> +#define KS_FILTER_HASH_NBITS	8
> +
> +/** A bucket for the hash table of integer Id numbers (kshark_hash_id). */
> +struct kshark_hash_id_item {
> +	/** Pointer to the Id in this bucket. */
> +	struct kshark_hash_id_item	*next;
> +
> +	/** The Id value. */
> +	int				id;
> +};
> +
> +/**
> + * Hash table of integer Id numbers. To be used for fast filter of trace
> + * entries.
> + */
> +struct kshark_hash_id {
> +	/** Array of buckets. */
> +	struct kshark_hash_id_item	**hash;
> +
> +	/** The number of Ids in the table. */
> +	size_t	count;
> +
> +	/**
> +	 * The number of bits used by the hashing function.
> +	 * Note that the number of buckets in the table if given by
> +	 * 1 << n_bits.
> +	 */
> +	size_t	n_bits;
> +};

  reply index

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 13:41 [PATCH 00/15] Start KernelShark v2 transformation Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 01/15] kernel-shark: split kernel-shark from trace-cmd repo Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 02/15] kernel-shark: Version 1.2.0 Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 03/15] kernel-shark: Start introducing KernelShark 2.0 Yordan Karadzhov (VMware)
2020-10-07 20:08   ` Steven Rostedt
2020-09-29 13:41 ` [PATCH 04/15] kernel-shark: Use only signed types in kshark_entry Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 05/15] kernel-shark: Introduce libkshark-hash Yordan Karadzhov (VMware)
2020-10-06 21:02   ` Steven Rostedt [this message]
2020-09-29 13:41 ` [PATCH 06/15] kernel-shark: Introduce Data streams Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 07/15] kernel-shark: Add stream_id to kshark_entry Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 08/15] kernel-shark: Integrate the stream definitions with the C API Yordan Karadzhov (VMware)
2020-10-07 20:12   ` Steven Rostedt
2020-10-08  7:17     ` Yordan Karadzhov (VMware)
2020-10-07 20:29   ` Steven Rostedt
2020-09-29 13:41 ` [PATCH 09/15] kernel-shark: Provide merging of multiple data streams Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 10/15] kernel-shark: Integrate the stream definitions with data model Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 11/15] kernel-shark: Use only signed types for model defs Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 12/15] kernel-shark: Add ksmodel_get_bin() Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 13/15] kernel-shark: Protect ksmodel_set_in_range_bining() Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 14/15] kernel-shark: Add methods for time calibration Yordan Karadzhov (VMware)
2020-09-29 13:41 ` [PATCH 15/15] kernel-shark: Integrate streams with libkshark-configio Yordan Karadzhov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201006170222.0093ab92@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org
	public-inbox-index linux-trace-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git