Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp299061lql; Mon, 11 Mar 2024 03:09:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXu0GFKBmr5vV2jPoVdiAeJUifopemxDHqnu5VA0TLO0R4nmdoEK5NS4kA76fkQmlUDj2r5ucKM8ElKyYtEstIF5zrQubTJBUhFBP1HyQ== X-Google-Smtp-Source: AGHT+IH9nSxjKZe0uAKhwhBvqd26vp1RcrNgj3IqlrydT25tzKIup2jLfJ6AgoRQK7DtmXAzlZ0M X-Received: by 2002:a17:903:22c5:b0:1dc:f7b1:be18 with SMTP id y5-20020a17090322c500b001dcf7b1be18mr8872665plg.23.1710151761555; Mon, 11 Mar 2024 03:09:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710151761; cv=pass; d=google.com; s=arc-20160816; b=K0T6WGZUlwOOvj2ELn0CFGN++vGhcw4v4HNPEcdJpar9KZNaaMQqx6Fl3MPwXn1jfy BPBw95tTjf/kqgDqFtREVTBw36f+OJEf5VJRk6hywY0wUSW2VAvV8yMyx06xhSZyAHM5 EwQ1ZpX+B3IRR5trOjhbt9QP3n6K5CxEMwUMlAENo9YN1+8dgHJhsynLeE0vTibUH67J 495eZIaTXDYtYqh6UiFdtV5c3RHzYLb43Q7ZsZm7F7Krnzgts6sfqlmJVx960D6Fqfa9 MIsoK6BBJuyrh2gAoDrbJLdvzf6+69j9njfUoFcxsl0Z2OT56bD33QObYrZn9q+KkGdT ZRyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=COk9Hgw7UUv/majYTm6xgyl0r4CF+hFW+Xu+o52Rd4c=; fh=nQDbXpoDV5Bi1YgBVfhg2voF9rKfbZapBYQats8nzUM=; b=ETyTVlMXqWnc+0vRwy+Ns/YUt/V2WGoHxirEBgivUQSIDl9hrcQHrNdEYviDuZ++HQ 8/Hfw2riJ22O9tYWHonl1jirXyBkm8a4z39DeLS17qPLU/k8t3DPZwipll3VlAxhztb8 a++QSHCV2hkJRXALLma1TMccpgJmkZhRZJyFJiAFoxY+cCmPLGX1yuwbtC4aZTNd4OED cwJAnBoDFp3R2CyWpF0IFGzRdg/Iq+2QIGQO9/a3NCDmqaXmfHG5aAluaMP2UIAptwlp WBMndSFWJjf5jEqF01p6eArJIxBKym+TQH8AuJ9Duftkohf4r1YWiw09QcuKRXZZk0EK PysQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-98670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98670-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d1-20020a170902cec100b001dda17fe7b6si1212809plg.590.2024.03.11.03.09.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 03:09:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-98670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98670-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C59DDB217AB for ; Mon, 11 Mar 2024 10:09:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 271BE2BB14; Mon, 11 Mar 2024 10:09:01 +0000 (UTC) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0034929424; Mon, 11 Mar 2024 10:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710151740; cv=none; b=Qq9FsziI2wS+vDcsV/bPvJHomlgyg4hDXjBgTwPQY8NQN4t4fThGYQFE3FEe1yuxYbGl3SGw3j+MaebE3tu4vT9usbqdX52/xeHb1Q+A0mHA9R4IUwWOqQcTdBPqR2CLrTY40M5XRhSg/HnjvadlqnoPciddyyLTQhaxlQQc/K0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710151740; c=relaxed/simple; bh=R/LFo6fpPzqsm2Yzj85bW4UQWwKnVon7xRV4xVdmeWQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CZhngm9DX4/des/fAbazssjjGQ30DkKsIQzey0ud8WPrfv/pNulZFqHkWKc7gdtKcY/NhD+8ximB4s4fhuVMJiudQhZzb+9kIanPHAXdIiZkwcjsyt3RBKsBMXVmNJ1ouPOAXEpIf3b9ADqSxGk9sw/9J03L/PSxXS8X7fod4aY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a44f2d894b7so522427666b.1; Mon, 11 Mar 2024 03:08:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710151737; x=1710756537; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=COk9Hgw7UUv/majYTm6xgyl0r4CF+hFW+Xu+o52Rd4c=; b=Wb0nEJvlGjJDnUSG4UtFXTqOKBeBEvEAHYbRn7SRF8sheInCrp/qdcErOcW2ozBO1X BPVlkfADdimlU9/pGcmNtIDKUEHoAz74vHn0kiENSGpLpBGzKs4zlEgxapKldPZ0Avf8 4hVpmeacSDG3Gnvd+p0pzpqR6HhXDE19iAx5/59RO/A4zDUZ1Ln8pyAVYFpdpi4akNAp 7tOuW07kyA1kZ1E6Nc8ngWu02ZBmQ28TWyWiM7qYiEKgP84uCebxjzFgiVKZlC8lTcjp HElwsl4lNID8C45ucWmMTJ21hca7KT5I0k55yUxyp5abnpV3cdjAgLm27fdsJc8LS70D w3jw== X-Forwarded-Encrypted: i=1; AJvYcCXG3tkLGK+d0oQQYxOsyZuOKSSXgHWdws8BLNOTtXpV0F/vxS8ElNoqVNW67ZECPW4KbpGGEwByvJimmIDavAOKogUMwswNrFAW6aNVuMzCGj1GdV8bYakkDRs8tiqlL/VCFiAG9iVTBg== X-Gm-Message-State: AOJu0Ywh4mDiLxnMkIr8GwnJDQw896X2/3F/Bi5Y/FMJSZ88KDM0A95j fIy9jQzXuGGipdVth+46vFINsJTAmz9JqU7Hxsba51VO3mTqg6px5GV41AbV X-Received: by 2002:a17:907:2cc6:b0:a45:d17e:202b with SMTP id hg6-20020a1709072cc600b00a45d17e202bmr4781951ejc.41.1710151737246; Mon, 11 Mar 2024 03:08:57 -0700 (PDT) Received: from gmail.com (fwdproxy-lla-120.fbsv.net. [2a03:2880:30ff:78::face:b00c]) by smtp.gmail.com with ESMTPSA id h16-20020a1709067cd000b00a45f63d2959sm2690693ejp.210.2024.03.11.03.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 03:08:56 -0700 (PDT) Date: Mon, 11 Mar 2024 03:08:54 -0700 From: Breno Leitao To: Leon Romanovsky Cc: Dennis Dalessandro , Jason Gunthorpe , kuba@kernel.org, keescook@chromium.org, "open list:HFI1 DRIVER" , open list Subject: Re: [PATCH net-next] IB/hfi1: allocate dummy net_device dynamically Message-ID: References: <20240308182951.2137779-1-leitao@debian.org> <20240310101451.GD12921@unreal> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240310101451.GD12921@unreal> Hello Leon, On Sun, Mar 10, 2024 at 12:14:51PM +0200, Leon Romanovsky wrote: > On Fri, Mar 08, 2024 at 10:29:50AM -0800, Breno Leitao wrote: > > struct net_device shouldn't be embedded into any structure, instead, > > the owner should use the priv space to embed their state into net_device. > > Why? From my experience, you can leverage all the helpers to deal with the relationship between struct net_device and you private structure. Here are some examples that comes to my mind: * alloc_netdev() allocates the private structure for you * netdev_priv() gets the private structure for you * dev->priv_destructor sets the destructure to be called when the interface goes away or failures. > > @@ -360,7 +360,11 @@ int hfi1_alloc_rx(struct hfi1_devdata *dd) > > if (!rx) > > return -ENOMEM; > > rx->dd = dd; > > - init_dummy_netdev(&rx->rx_napi); > > + rx->rx_napi = alloc_netdev(sizeof(struct iwl_trans_pcie *), > > + "dummy", NET_NAME_UNKNOWN, > > Will it create multiple "dummy" netdev in the system? Will all devices > have the same "dummy" name? Are these devices visible to userspace? This allocation are using NET_NAME_UNKNOWN, which implies that the device is not expose to userspace. Would you prefer a different name? > > + init_dummy_netdev); + if > > (!rx->rx_napi) + return -ENOMEM; > > You forgot to release previously allocated "rx" here. Good catch, I will update. Thanks