DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Sivaprasad Tummala <sivaprasad.tummala@amd.com>,
	<david.hunt@intel.com>, <jerinj@marvell.com>,
	<harry.van.haaren@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [RFC PATCH 4/5] power: add eventdev support for power management
Date: Wed, 17 May 2023 15:43:50 +0100	[thread overview]
Message-ID: <1cecb5a2-3089-d862-8614-77bb6bea3f17@intel.com> (raw)
In-Reply-To: <20230419095427.563185-4-sivaprasad.tummala@amd.com>

On 4/19/2023 10:54 AM, Sivaprasad Tummala wrote:
> Add eventdev support to enable power saving when no events
> are arriving. It is based on counting the number of empty
> polls and, when the number reaches a certain threshold, entering
> an architecture-defined optimized power state that will either wait
> until a TSC timestamp expires, or when events arrive.
> 
> This API mandates a core-to-single-port mapping (i.e. one core polling
> multiple ports of event device is not supported). This should be ok
> as the general use case will have one CPU core using one port to
> enqueue/dequeue events from an eventdev.
> 
> This design is using Eventdev PMD Dequeue callbacks.
> 
> 1. MWAITX/MONITORX:
> 
>     When a certain threshold of empty polls is reached, the core will go
>     into a power optimized sleep while waiting on an address of next RX
>     descriptor to be written to.
> 
> 2. Pause instruction
> 
>     This method uses the pause instruction to avoid busy polling.
> 
> Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> ---

Hi, few comments

> +
> +static uint16_t
> +evt_clb_pause(uint8_t dev_id __rte_unused, uint8_t port_id __rte_unused,
> +		struct rte_event *ev __rte_unused,
> +		uint16_t nb_events, void *arg)
> +{
> +	const unsigned int lcore = rte_lcore_id();
> +	struct queue_list_entry *queue_conf = arg;
> +	struct pmd_core_cfg *lcore_conf;
> +	const bool empty = nb_events == 0;
> +	uint32_t pause_duration = rte_power_pmd_mgmt_get_pause_duration();
> +
> +	lcore_conf = &lcore_cfgs[lcore];
> +
> +	if (likely(!empty))
> +		/* early exit */
> +		queue_reset(lcore_conf, queue_conf);
> +	else {
> +		/* can this queue sleep? */
> +		if (!queue_can_sleep(lcore_conf, queue_conf))
> +			return nb_events;
> +
> +		/* can this lcore sleep? */
> +		if (!lcore_can_sleep(lcore_conf))
> +			return nb_events;
> +
> +		uint64_t i;
> +		for (i = 0; i < global_data.pause_per_us * pause_duration; i++)
> +			rte_pause();

Why not add support for TPAUSE? This is generic code, ethdev code path 
supports it, and most of this function is duplicated from ethdev 
implementation. I wish we could unify them somehow, but I can't think of 
an elegant way to do it off the top of my head.

> +
> +	/* we need this in various places */
> +	rte_cpu_get_intrinsics_support(&global_data.intrinsics_support);
> +
> +	switch (mode) {
> +	case RTE_POWER_MGMT_TYPE_MONITOR:
> +		/* check if we can add a new port */
> +		ret = check_evt_monitor(lcore_cfg, &qdata);
> +		if (ret < 0)
> +			goto end;
> +
> +		clb = evt_clb_umwait;
> +		break;
> +	case RTE_POWER_MGMT_TYPE_PAUSE:
> +		/* figure out various time-to-tsc conversions */
> +		if (global_data.tsc_per_us == 0)
> +			calc_tsc();
> +
> +		clb = evt_clb_pause;
> +		break;
> +	default:
> +		RTE_LOG(DEBUG, POWER, "Invalid power management type\n");

Technically, if we specify "scale" here, the power management scheme 
would be *unsupported* rather than *invalid*, and thus should return 
-ENOTSUP rather than -EINVAL.

Also, since this is generic code, theoretically this code could in fact 
support SCALE mode? Would it make sense for eventdev to use that scheme?

> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
> + *
> + * Disable power management on a specified Ethernet device Rx queue and lcore.
> + *
> + * @note This function is not thread-safe.
> + *
> + * @warning This function must be called when all affected Ethernet queues are
> + *   stopped and no Rx/Tx is in progress!
> + *
> + * @param lcore_id
> + *   The lcore the Rx queue is polled from.
> + * @param dev_id
> + *   The identifier of the device.
> + * @param port_id
> + *   Event port identifier of the Event device.
> + * @return
> + *   0 on success
> + *   <0 on error
> + */
> +__rte_experimental
> +int
> +rte_power_eventdev_pmgmt_port_disable(unsigned int lcore_id,
> +		uint8_t dev_id, uint8_t port_id);

It would've been nice if we didn't have to reimplement the same logic 
for every new device type, but seeing how we do not have any unified 
driver API, I don't have any bright ideas on how to do it better.

-- 
Thanks,
Anatoly


  reply	other threads:[~2023-05-17 14:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19  9:54 [RFC PATCH 1/5] eventdev: add power monitoring API on event port Sivaprasad Tummala
2023-04-19  9:54 ` [RFC PATCH 2/5] event/sw: support power monitor Sivaprasad Tummala
2023-04-19  9:54 ` [RFC PATCH 3/5] eventdev: support optional dequeue callbacks Sivaprasad Tummala
2023-04-24 16:06   ` Ferruh Yigit
2023-05-17 14:22   ` Burakov, Anatoly
2023-04-19  9:54 ` [RFC PATCH 4/5] power: add eventdev support for power management Sivaprasad Tummala
2023-05-17 14:43   ` Burakov, Anatoly [this message]
2023-05-24 12:34     ` Tummala, Sivaprasad
2023-04-19  9:54 ` [RFC PATCH 5/5] examples/eventdev_p: add eventdev " Sivaprasad Tummala
2023-04-19 10:15 ` [RFC PATCH 1/5] eventdev: add power monitoring API on event port Jerin Jacob
2023-04-24 16:06   ` Ferruh Yigit
2023-04-25  4:09     ` Jerin Jacob
2023-05-02 11:19       ` Ferruh Yigit
2023-05-03  7:58         ` Jerin Jacob
2023-05-03  8:13           ` Ferruh Yigit
2023-05-03  8:26             ` Jerin Jacob
2023-05-03 15:11               ` Tummala, Sivaprasad
2023-04-25  6:19     ` Mattias Rönnblom
2023-05-02 10:43       ` Ferruh Yigit
2023-05-17 14:48 ` Burakov, Anatoly
2023-10-16 20:57 ` [PATCH v1 1/6] " Sivaprasad Tummala
2023-10-16 20:57   ` [PATCH v1 2/6] event/sw: support power monitor Sivaprasad Tummala
2023-10-16 23:41     ` Tyler Retzlaff
2023-10-16 20:57   ` [PATCH v1 3/6] eventdev: support optional dequeue callbacks Sivaprasad Tummala
2023-10-16 23:47     ` Tyler Retzlaff
2023-10-16 20:57   ` [PATCH v1 4/6] event/sw: " Sivaprasad Tummala
2023-10-16 20:57   ` [PATCH v1 5/6] power: add eventdev support for power management Sivaprasad Tummala
2023-10-16 23:51     ` Tyler Retzlaff
2023-10-17  3:03       ` Tummala, Sivaprasad
2023-10-17  3:22     ` Jerin Jacob
2023-10-18  7:08       ` Tummala, Sivaprasad
2023-10-18  7:13         ` Jerin Jacob
2023-10-16 20:57   ` [PATCH v1 6/6] examples/eventdev_p: add eventdev " Sivaprasad Tummala

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=1cecb5a2-3089-d862-8614-77bb6bea3f17@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=jerinj@marvell.com \
    --cc=sivaprasad.tummala@amd.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).