From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6299A196 for ; Wed, 22 Jan 2025 01:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737510362; cv=none; b=io+UY73qxOyU5MIP/SevQw+Srmw/mjbLpRMpUKIzIpj+dlmadViOiAQVcOWwgxyvuepR7cAyu+P+b5OOfYiwj9C8OkzMfAWVYiFkGPNbmPdqRrFPJWf9Enke0SMPJz6nc+IIAGPRct95ZE2fs9cDDGJa2Xb8JrvJHJPIqFiMD/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737510362; c=relaxed/simple; bh=Ghq6Y7uEEnfYw9FpVBupi0g4gTt/EcB2SuJ/Lx/yJS0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ia6AnSJV4jjf1ng/lIopzpqeELjpTAfnujq5Uans0QPU5YoSgCjH5n4pudU2JeUAiWmjtMKUMgDCtfcn9FwufLZwEjDseL1VAjwUb8FX8z9dDlwrB5tOrMMIRd2GdFeY8xpFJNjlGV/nzkKiyZ91+0rZHKYhqHm569LKsIqME2Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=pc5p6E0b; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="pc5p6E0b" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CatT+SOWonYEFu29hHPhMXqpsu2TzWx4x9ET4AttseI=; b=pc5p6E0bR7cQds1Lct+g6sSA8o 2dggOp7mKTxBjwF7KxTNxGBAhQctvJ85EhRwuAxA0I4s+pYPsSg2yVwYwnYxXqS0YP8iJk+y5uHXO +BiNXR2qvK/uNnb4dwpd421dOLj3ZfC7JUocLs45dz/tscgRrMObRh8VqUA+vtxfBX5CTELHk8Uf5 Cfxa381oywx7wi1BVGNbw8XF9jcn2rYOY9g4jfurAWIMQhILaTjC9GgIjKaV4UPPQ5UH6+nIdYAjL CyraO8gMBKoO2mQkb+NQBt/UTR0YYXdReTxq1a+QdlJYpcAvve19ICkUWfzBE/kTIrLFUWg8+n3Nd LDWEvVsQ==; Received: from [58.29.143.236] (helo=[192.168.1.6]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1taPoV-000SES-Ci; Wed, 22 Jan 2025 02:45:51 +0100 Message-ID: <89d98a0c-8d62-45c7-a213-b72052019ed8@igalia.com> Date: Wed, 22 Jan 2025 10:45:46 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/7] sched_ext: Implement event counter infrastructure and add an event To: Leonardo Temperanza , tj@kernel.org, void@manifault.com, arighi@nvidia.com Cc: kernel-dev@igalia.com, linux-kernel@vger.kernel.org References: <20250116151543.80163-1-changwoo@igalia.com> <20250116151543.80163-2-changwoo@igalia.com> <5c1f6f0b-2b9d-4b16-8ec0-e3be876eb260@gmail.com> From: Changwoo Min Content-Language: en-US, ko-KR, en-US-large, ko In-Reply-To: <5c1f6f0b-2b9d-4b16-8ec0-e3be876eb260@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Leonardo, Thanks for the review. On 25. 1. 22. 00:00, Leonardo Temperanza wrote: > scx_event_stat fields are required to be u64, otherwise the macros below > don't work correctly. Perhaps a comment could highlight this "hidden" > constraint? As well as a BUILD_BUG_ON to verify that this constraint is > verified at build time. That's a good suggestion. I will add any hidden constratins in the comments. > If an event is added to scx_event_kind but not scx_event_stat_str, the > array can possibly be accessed out of bounds (or into a NULL string > depending on the missing index). The GNU C extension could be used to > initialize all elements to the empty string "", like this: > > static const char *scx_event_stat_str[SCX_EVENT_END] = { >     [0 ... SCX_EVENT_END - 1] = "", >     [SCX_EVENT_INVAL_SELECT_CPU] = "invalid_select_cpu", > }; > > Alternatively a helper could be used: > > static const char *scx_event_name(enum scx_event_kind kind) > { >     return scx_event_stat_str[kind] ? : ""; > } Thanks for the suggestion. I am considering dropping event and event_str in the next version. That is because the only purpose of the event things is to print dump messages. At this point, the simpler the better, I think. >> +/** >> + * scx_read_event_kind - Read an event from 'e' with 'kind' >> + * @e: a pointer to an event collected by scx_bpf_event_stat() >> + * @kine: an event type defined in scx_event_kind >> + */ >> +#define scx_read_event_kind(e, kind) ({                        \ >> +    u64 *__e64 = (u64 *)(e);                        \ >> +    __e64[kind];                                \ >> +}) >> + > > > nit: typo, "@kine" instead of "@kind" Good catch. Will fix it. Regards, Changwoo Min