From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f169.google.com (mail-it1-f169.google.com [209.85.166.169]) by dpdk.org (Postfix) with ESMTP id 22F701B6EB for ; Mon, 17 Dec 2018 10:12:10 +0100 (CET) Received: by mail-it1-f169.google.com with SMTP id h193so18834011ita.5 for ; Mon, 17 Dec 2018 01:12:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=JHxcUiRv9iiVh6h1C12oEF8v/sFl2kGwTLcx4ZzutR0=; b=fK5fGVjd7tvhbkKknK0VmOVgkq0eYbsK6hKuDwET7QgY/+iRT1SDyfXk0appRs5Rf/ j2zdbWFLSQtwNdLCUi2IsWEry6D9/u8gY05GRKWIpOJZIISi3OkfP21uUwePNlRJCzfI 68DBkCYKW843QQbYYtUfqboTz+IomaQ4Haok68vrgVQdxm7idi+oLRmbMr+P2r3OKmkY DPMR7i7NkTSuCFTO/dtqa7DB9mxxnzegl8TjfJ5fQyrJwWW5EvlBzRt4ktt0urBk9Ucf tOK9EhWnesppBsgdc5h2XnNKldfng6yZmaqxVrX1mYjeZfPsaUlmO4Vip83O54tDE8la XYCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=JHxcUiRv9iiVh6h1C12oEF8v/sFl2kGwTLcx4ZzutR0=; b=BxgQtdnuj2N17akYJay05GqimqsVhF3UPKysmG5i4tCQx3xpfEV3cQorAscVgOLWIh Gou5viGvCp6QxHYEuEuLqtCi+89klPGJRfg3hIz9PKiR45ktrTNd/nf7auQd5+Bsq/3w imm7TmCL+OKK/QbaojrKZIJBOl4nIINR7D2nSw0ADIixmiRKf7BeDkehJxUsHdNfe8Ck tUJ2gicCjyewrTb1bOH1rmnTxIee9Fw9sgPf0woWhA3F0KZ6zhslDY6yf9T4gTiu4rM6 Xv2eCjjeqX9CUBKcyK8e6ntmHN5cWlA1ZWTLJm/leRVx5whkIkYHuolO2Jg5VOBZHl6q r4Nw== X-Gm-Message-State: AA+aEWY0wK5f9D3GsXTtK/KM/Lz++YKoglwGoPlMEelOwSldF2rawbhy /U1fXOHeEcUujOq+fj7Di1mNZFPPyRNtmZeEzVdOd7Ux X-Google-Smtp-Source: AFSGD/X/Mgb9XuRW1HYom1dCqH9jsCa1Aa8BsIuGdi4keif6mmshmLeTteST/kYj4NHlIDTsQpDCgdoBwNwUFkE4sss= X-Received: by 2002:a24:7596:: with SMTP id y144mr12047444itc.68.1545037929261; Mon, 17 Dec 2018 01:12:09 -0800 (PST) MIME-Version: 1.0 From: Miao Yan Date: Mon, 17 Dec 2018 17:12:01 +0800 Message-ID: To: users@dpdk.org Content-Type: text/plain; charset="UTF-8" Subject: [dpdk-users] Possible race in bonding driver ? X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Dec 2018 09:12:10 -0000 Hello Experts, I am currently working on a project to implement a new team policy based on the bonding driver. Basically, I have lots of 'ports', each of them has a ID. I'd like to use the ID to calculate the hash and distribute the traffic to different slave ports, similar to round-robin, except the sender ID is fixed. And when looking into bonding driver code, the following code looks like racy: static uint16_t bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { ... /* Copy slave list to protect against slave up/down changes during tx * bursting */ num_of_slaves = internals->active_slave_count; memcpy(slaves, internals->active_slaves, sizeof(internals->active_slaves[0]) * num_of_slaves); [...] } void deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id) { [...] /* If slave was not at the end of the list * shift active slaves up active array list */ if (slave_pos < active_count) { active_count--; memmove(internals->active_slaves + slave_pos, internals->active_slaves + slave_pos + 1, (active_count - slave_pos) * sizeof(internals->active_slaves[0])); } [...] } What if a core is dumping packets to the bond device and at the same time a slave is down and another core is handling the deactivation (or it could be just another core calling rte_bond_slave_remove). It seems it's possible for the TX core to see a partially updated active_slaves array during memmove. Is this a problem or am I missing something ? Thank you for the help. Regards, Miao