DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH 00/13] make signal handlers async-signal-safe
Date: Mon, 7 Sep 2026 10:06:25 +0100	[thread overview]
Message-ID: <ap5-kVogL7vP-0oI@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20260906232716.496546-1-stephen@networkplumber.org>

On Sun, Sep 06, 2026 at 04:24:35PM -0700, Stephen Hemminger wrote:
> Signal handlers may only call the functions listed in signal-safety(7).
> Many DPDK examples ignored this and did printf() a "preparing to exit"
> message before setting the quit flag. A signal during another printf
> call can deadlock. And some of the programs did even more
> unsafe things.
> 
> GCC 14 -fanalyzer reports these:
> 
>   warning: call to 'printf' from within signal handler [CWE-479]
> 	[-Wanalyzer-unsafe-call-within-signal-handler]
> 
> The fix is the same throughout: the handler only sets the existing
> volatile flag, and any real work moves to the main loop or to main()
> after the lcores are joined. The message is dropped; the user pressed ^C
> and knows a signal was sent.
> 
> Patches 1-2 only delete the printf(). Patches 3-13 also relocate work
> that was being done in the handler.
> 
> Behaviour changes worth review:
> 
> - examples/ntb: SIGINT used to printf(), restore SIG_DFL and re-raise,
>   killing the process without stopping the forwarding lcores or closing
>   the devices. It now sets the per-lcore stopped flag, so SIGINT stops
>   forwarding and returns to the ntb> prompt; quit does the teardown.
> 
> - examples/vdpa: the teardown moved to main() now also closes the vDPA
>   devices when leaving interactive mode, which was missing before.
> 
> - examples/eventdev_pipeline: the second-signal escape hatch becomes
>   _exit() instead of rte_exit(), the --dump-dev exit dump moves to
>   main() (and uses the real dev_id rather than a hardcoded 0), and
>   SIGTSTP now sets cdata.dump_dev_signal, which schedule_devices()
>   already drained but nothing ever set. The SIGTSTP dump therefore
>   requires a scheduler lcore.
> 
> Only examples/ethtool and examples/vmdq_dcb carry a Fixes: tag; the rest
> remove an unsafe call that has not been seen to deadlock in practice and
> are cleanups rather than backport material.
> 
> Applications outside the analyzer's reach likely have the same pattern;
> this covers what GCC flagged, plus eventdev_pipeline found by inspection.
> 
> Build tested with GCC 14 -fanalyzer; the warnings are gone for the files
> touched.
> 
> Stephen Hemminger (13):
>   graph: do not call printf in signal
>   examples: remove printf from signal handler
>   examples/vmdq: do not print from signal handler
>   examples/symmetric_mp: do not print or exit in handler
>   examples/vdpa: make signal handler safe
>   examples/vhost: make signal handler safe
>   examples/vhost_blk: do not tear down from signal handler
>   examples/ntb: do not print and re-raise from signal handler
>   examples/ipsecgw: do not print from signal handler
>   examples/l2fwd-macsec: remove print in signal handler
>   examples/ethtool: fix exit flag and unchecked cmdline
>   examples/vmdq_dcb: allow exit on signal
>   examples/eventdev_pipeline: make signal handler safe
> 
Series-Acked-by: Bruce Richardson <bruce.richardson@intel.com>

  parent reply	other threads:[~2026-09-07  9:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 23:24 [PATCH 00/13] make signal handlers async-signal-safe Stephen Hemminger
2026-09-06 23:24 ` [PATCH 01/13] graph: do not call printf in signal Stephen Hemminger
2026-09-06 23:24 ` [PATCH 02/13] examples: remove printf from signal handler Stephen Hemminger
2026-09-06 23:24 ` [PATCH 03/13] examples/vmdq: do not print " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 04/13] examples/symmetric_mp: do not print or exit in handler Stephen Hemminger
2026-09-06 23:24 ` [PATCH 05/13] examples/vdpa: make signal handler safe Stephen Hemminger
2026-09-06 23:24 ` [PATCH 06/13] examples/vhost: " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 07/13] examples/vhost_blk: do not tear down from signal handler Stephen Hemminger
2026-09-06 23:24 ` [PATCH 08/13] examples/ntb: do not print and re-raise " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 09/13] examples/ipsecgw: do not print " Stephen Hemminger
2026-09-08 11:19   ` Radu Nicolau
2026-09-06 23:24 ` [PATCH 10/13] examples/l2fwd-macsec: remove print in " Stephen Hemminger
2026-09-06 23:24 ` [PATCH 11/13] examples/ethtool: fix exit flag and unchecked cmdline Stephen Hemminger
2026-09-06 23:24 ` [PATCH 12/13] examples/vmdq_dcb: allow exit on signal Stephen Hemminger
2026-09-06 23:24 ` [PATCH 13/13] examples/eventdev_pipeline: make signal handler safe Stephen Hemminger
2026-09-07  9:06 ` Bruce Richardson [this message]
2026-09-07 17:03 ` [PATCH v2 00/13] make signal handlers async-signal-safe Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 01/13] graph: do not call printf in signal Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 02/13] examples: remove printf from signal handler Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 03/13] examples/vmdq: do not print " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 04/13] examples/symmetric_mp: do not print or exit in handler Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 05/13] examples/vdpa: make signal handler safe Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 06/13] examples/vhost: " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 07/13] examples/vhost_blk: do not tear down from signal handler Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 08/13] examples/ntb: do not print and re-raise " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 09/13] examples/ipsecgw: do not print " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 10/13] examples/l2fwd-macsec: remove print in " Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 11/13] examples/ethtool: fix exit flag and unchecked cmdline Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 12/13] examples/vmdq_dcb: allow exit on signal Stephen Hemminger
2026-09-07 17:03   ` [PATCH v2 13/13] examples/eventdev_pipeline: make signal handler safe Stephen Hemminger

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=ap5-kVogL7vP-0oI@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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