From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1BF59A0547; Fri, 12 Feb 2021 00:16:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B00822A1FF; Fri, 12 Feb 2021 00:16:14 +0100 (CET) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id A994422A1FB for ; Fri, 12 Feb 2021 00:16:13 +0100 (CET) Received: by mail-pj1-f46.google.com with SMTP id cv23so4326028pjb.5 for ; Thu, 11 Feb 2021 15:16:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5O3PF4lXieOWiNSRMpK4kQ2H4h8RpxNfICBRC/G8Kn4=; b=V7mzLFfE+1n6pOXpDhM3zS1bwSI17WUCCamiLd8Y81qK36pRpmN3NULAbxlHmHkKKO yleBvjEHcgy8TYzPOOMVBo6BgPEaQ7ZOUGTxOu838TrCDNN44gjRWlF7sEC9N6re5F4N Oo7WiRkoPrYPuTj0ou1uwPJEhxRN9Y9B0L3bb4AAbtJXvIYsqZLDJyzdnSJjUcgcs2od YhqJN7kwnnjNQG73+K+58GrWjRmfl7Aadt9nQeb5ki3bcDrks5t0lrbzHWqe7gwXes/S OSf2ZKSLjPRh883n7q875h2HGCbnPtYJElaq63eQaW9a83t/OOpMw1tEjRzlsN8vEdRE yIkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5O3PF4lXieOWiNSRMpK4kQ2H4h8RpxNfICBRC/G8Kn4=; b=NGyEJGNLcDG7U3U8qU/XwWnFEUmY+qWP45YkDBHEyh/N6WbsFw+oc+r67ly24vwu6r FnhIgzrhszNuYzXDSlsLzo/Ju9/6wyt+NQDtQ8hkN58I6ufmomxzs2yIkdXimTj9qIQJ LKFPortSVz0HxdjO3fVGAPt3WhYXLsFItNAhOAu0BJRK3FuXYbJLmjsFiQg5+9vcUefy FxyuAfgFNbeZ/caOUnxc/8fW6056hOpUN4fWqa7p7j+G6STFJKylmu6fbuzIWgRU7GZW /Gpg7T3T+A3AM2qoc4nWmm7jCuVJoOiIWlKp66l4FodeFUDXRsOtikAMbPy4c1jkV+Id R58A== X-Gm-Message-State: AOAM533R+g3j/lLufSwNoEDNdfuuNQdBkt9n3nLIQaVholZp5W4s1+PM gBoY53084QV7G/qbuVSEw34ndw== X-Google-Smtp-Source: ABdhPJzYY2osOrp5XM+QxSLYgeQ2RwYbxvzNK/xXeF/ATBVUFjZvbMBPMhF68O719iLp3UtaZ70mhA== X-Received: by 2002:a17:90b:4844:: with SMTP id lf4mr59884pjb.23.1613085372809; Thu, 11 Feb 2021 15:16:12 -0800 (PST) Received: from hermes.local (76-14-222-244.or.wavecable.com. [76.14.222.244]) by smtp.gmail.com with ESMTPSA id c15sm6053801pjc.46.2021.02.11.15.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:16:12 -0800 (PST) Date: Thu, 11 Feb 2021 15:16:02 -0800 From: Stephen Hemminger To: Thomas Monjalon Cc: Sarosh Arif , sthemmin@microsoft.com, dev@dpdk.org Message-ID: <20210211151602.78260c9a@hermes.local> In-Reply-To: <7682463.TU6WbEMXMz@thomas> References: <20210210061605.30648-1-sarosh.arif@emumba.com> <20210211082004.23626-1-sarosh.arif@emumba.com> <7682463.TU6WbEMXMz@thomas> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [v4 PATCH] usertools: show valid hugepage sizes if user requests an invalid hugepage size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 11 Feb 2021 22:44:03 +0100 Thomas Monjalon wrote: > 11/02/2021 09:20, Sarosh Arif: > > If user requests a hugepage size which is not supported by the system, > > currently user gets an error message saying that the requested size > > is not a valid system huge page size. In addition to this if we display > > the valid hugepage sizes it will be convenient for the user to request > > the right size next time. > > > > Signed-off-by: Sarosh Arif > > --- > > --- a/usertools/dpdk-hugepages.py > > +++ b/usertools/dpdk-hugepages.py > > @@ -43,6 +43,12 @@ def is_numa(): > > return os.path.exists('/sys/devices/system/node') > > > > > > +def get_valid_page_sizes(path): > > + '''Extract valid hugepage sizes''' > > + dir = os.path.dirname(path) > > + pg_sizes = (d.split("-")[1] for d in os.listdir(dir)) > > + return " ".join(pg_sizes) > > + > > A second blank line is required here. > > > def get_hugepages(path): > > '''Read number of reserved pages''' > > with open(path + '/nr_hugepages') as nr_hugepages: > > @@ -59,9 +65,8 @@ def set_hugepages(path, pages): > > except PermissionError: > > sys.exit('Permission denied: need to be root!') > > except FileNotFoundError: > > - filename = os.path.basename(path) > > - size = filename[10:] > > - sys.exit('{} is not a valid system huge page size'.format(size)) > > + sys.exit("Invalid page size. Valid page sizes: {}".format( > > + get_valid_page_sizes(path))) > > Alignment needs a small fixup. > > After these small changes, flake8 is OK. > > Applied, thanks. I used Yet-Another-Python-Formmatter originally (yapf). Its preferred style for that would be: diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py index fb368b693399..28eba86641f7 100755 --- a/usertools/dpdk-hugepages.py +++ b/usertools/dpdk-hugepages.py @@ -67,7 +67,7 @@ def set_hugepages(path, pages): sys.exit('Permission denied: need to be root!') except FileNotFoundError: sys.exit("Invalid page size. Valid page sizes: {}".format( - get_valid_page_sizes(path))) + get_valid_page_sizes(path))) if get_hugepages(path) != pages: sys.exit('Unable to reserve required pages.')