From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id AB970A0509;
	Thu, 14 Apr 2022 21:03:13 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 9DF884067E;
	Thu, 14 Apr 2022 21:03:13 +0200 (CEST)
Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com
 [209.85.167.45]) by mails.dpdk.org (Postfix) with ESMTP id 313AF4067C
 for <dev@dpdk.org>; Thu, 14 Apr 2022 21:03:12 +0200 (CEST)
Received: by mail-lf1-f45.google.com with SMTP id bu29so10779083lfb.0
 for <dev@dpdk.org>; Thu, 14 Apr 2022 12:03:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=date:from:to:cc:subject:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=zPOCd1FlcMVEivy+DApzqoWJOSB2CCDL3RXyIrUNvpc=;
 b=VbAl+Y70J0xhV+taLybD74eVRSM+Mj5CESFKOW5jiqiU7dWj3KJLZ1QlV4DofmnhUJ
 AUO+zmf+TP2gqWKCKlS5LIKtg6+o1+NXNAeZM+NwXAlYsc40EC4htfVFUKM87etIDoPU
 qB4aTr2z+Wu0OPTHEACBsfIC5QXy0mtgitjGsC1KSCevtF6DTbVQYQT12Kcjz2ptCiD7
 vNQxScwkEM8fIrM3WS/xlbDbY9yCBBfPe9Ii/DV21uXEMJrrTn6zFvvhGH3l9QK4irJx
 ifHjgmwZDtkdpou/UsbwaviKSwIxhs/UOEmz6ZiUkH+NK2EV4f2G/2guQjPIXMFgP7pE
 obzg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=zPOCd1FlcMVEivy+DApzqoWJOSB2CCDL3RXyIrUNvpc=;
 b=kErH9xx50AnMazS2Xt9DEge0h6icEofzBfRNiExm7P+TiYwJv1LVjhOpYlt+ysm6Hj
 Wp+PJQ7Zd1TmisFujlM+86opAvLQtTjyp9vviqDxmFb5cDw+QsNg/fTz6crCmEWz977h
 mcZqDEA5DjP26VXEtfe34Mily8X7J/bpjKSbYZvNkBzlVM1nSDSayyP3lEf6p1fSe1DP
 nLj1XTquNAzKC8e8t9xST8odQYC5EuChZNX0ic3UQ9EfCDfQIMo1SS1A8dUyy6ZB36MM
 KmH4404G7zAe+y4IZ8jK4Oy1Jic5qEN9xQX+okTUGbwmPdJWndwMgbv6pgofK6UDlzyk
 bs/w==
X-Gm-Message-State: AOAM532tq9CsCQ4IUrygG2nnFaMLRwcced7xilNUjgCrDGDXitYLIiPV
 VQ4FEASe1sk6y6uFW5TtxmI=
X-Google-Smtp-Source: ABdhPJw9Gvi2nCUpPSVztcAhlcfHHnpZusr5/G2At8CU41jmhFRySkPfkk1AKy2lAemQzuauA9ISmw==
X-Received: by 2002:a05:6512:13a7:b0:447:3dac:7a03 with SMTP id
 p39-20020a05651213a700b004473dac7a03mr2801403lfa.362.1649962991637; 
 Thu, 14 Apr 2022 12:03:11 -0700 (PDT)
Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru.
 [37.110.65.23]) by smtp.gmail.com with ESMTPSA id
 n11-20020a0565120acb00b0044aa30cb30csm82006lfu.6.2022.04.14.12.03.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 14 Apr 2022 12:03:11 -0700 (PDT)
Date: Thu, 14 Apr 2022 22:03:10 +0300
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: dev@dpdk.org, anatoly.burakov@intel.com
Subject: Re: rte_memzone_reserve and invalid socket id
Message-ID: <20220414220310.4eebc1dc@sovereign>
In-Reply-To: <20220413075425.GA8292@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
References: <20220329060436.GA22196@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
 <20220413075425.GA8292@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

2022-04-13 00:54 (UTC-0700), Tyler Retzlaff:
> On Mon, Mar 28, 2022 at 11:04:36PM -0700, Tyler Retzlaff wrote:
[...]
> > 	memzone3 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone3"), 1000,
> > 				1, 0);
> >                                 ^ socket_id (to repeat just make it invalid)
> > 
> > the parameter documentation provided for reference.
> > 
> >  * @param socket_id
> >  *   The socket identifier in the case of
> >  *   NUMA. The value can be SOCKET_ID_ANY if there is no NUMA
> >  *   constraint for the reserved zone.
> > 
> > of interest is should rte_memzone_reserve fail when provided a
> > completely invalid socket_id?

I think it should.

> > 
> > when running with --no-huge it does not because when --no-huge the
> > socket_id no matter the value is silently re-mapped to SOCKET_ID_ANY
> > though without --no-huge if a completely garbage socket_id were provided
> > it seems the allocation would fail.

It's an implementation detail.
NUMA could be respected for --no-huge if there was a need.

> > 
> > so you get different behavior for an invalid socket_id depending on
> > --no-huge vs with.
> > 
> > 	if (!rte_eal_has_hugepages() && socket_id < RTE_MAX_NUMA_NODES)
> > 		socket_id = SOCKET_ID_ANY;
> > 
> > the test later fails at this check. where it compares the memzone3
> > socket_id to what was used in the call to rte_memzone_reserve.
> > 
> > 	if (memzone3 != NULL && memzone3->socket_id != 1)
> > 		return -1;                ^ SOCKET_ID_ANY if --no-huge
> > 
> > if the allocation had failed, the test would pass instead of failing at
> > this point.
> > 
> > so what's wrong here? the test should be changed to expect different
> > behavior with --no-huge vs huge or should rte_memzone_reserve be
> > explicitly requiring SOCKET_ID_ANY instead of re-mapping invalid socket
> > id?

memzone3->socket_id == SOCKET_ID_ANY should not be possible,
because it's a specific selected socket ID.
Rather, the check should be relaxed depending on rte_eal_has_hugepages().