DPDK patches and discussions
 help / color / mirror / Atom feed
* [DPDK/other Bug 1588] sched: potential issue with memcmp of padding
@ 2024-11-20 23:38 bugzilla
  0 siblings, 0 replies; only message in thread
From: bugzilla @ 2024-11-20 23:38 UTC (permalink / raw)
  To: dev

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

https://bugs.dpdk.org/show_bug.cgi?id=1588

            Bug ID: 1588
           Summary: sched: potential issue with memcmp of padding
           Product: DPDK
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: Normal
         Component: other
          Assignee: dev@dpdk.org
          Reporter: stephen@networkplumber.org
  Target Milestone: ---

The tool PVS-studio flagged this code as a potential bug because of using
memcmp on a padded structure.

int
rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
        uint32_t subport_id,
        struct rte_sched_pipe_params *params,
        uint32_t *pipe_profile_id)
{
...
        /* Pipe profile should not exists */
        for (i = 0; i < s->n_pipe_profiles; i++)
                if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) {

The layout of the structure reported by pahole is:

struct rte_sched_pipe_profile {
        uint64_t                   tb_period;            /*     0     8 */
        uint64_t                   tb_credits_per_period; /*     8     8 */
        uint64_t                   tb_size;              /*    16     8 */
        uint64_t                   tc_period;            /*    24     8 */
        uint64_t                   tc_credits_per_period[13]; /*    32   104 */
        /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
        uint8_t                    tc_ov_weight;         /*   136     1 */
        uint8_t                    wrr_cost[4];          /*   137     4 */

        /* size: 144, cachelines: 3, members: 7 */
        /* padding: 3 */
        /* last cacheline: 16 bytes */
};

So the compiler will generate code comparing the last 3 bytes which is bad.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[-- Attachment #2: Type: text/html, Size: 3805 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-20 23:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-20 23:38 [DPDK/other Bug 1588] sched: potential issue with memcmp of padding bugzilla

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).