From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3329FA046B for ; Wed, 24 Jul 2019 18:28:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 04FA51C222; Wed, 24 Jul 2019 18:28:17 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 660571C218 for ; Wed, 24 Jul 2019 18:28:15 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id w24so22211965plp.2 for ; Wed, 24 Jul 2019 09:28:15 -0700 (PDT) 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=4Nb8DNkQq34GYhPUpCdC3NaYe2xGmxMJ4k6J9TBl/Sk=; b=hsnPXDvSdp5tiPXWluYm9XUWDrgAdF/XkLMlIa/FeKhblDGRMt59E+RQUIWXndTT5H Y/OEjisrHX2jXZ3aKrZhQB/Xo5eVoWx/+XkibY2hPODMkE305G/PG3/0/6+vUA9hw4eF tw3nziF0tZke0mioE0njoNrRa9VWmqkRkMQP1qskmck5HtS7hiELQrL9niSe3OL1s5uu 89Bhqvqjv000/zK5oEd+K09+J1S2bijjaM3xskZYCJvCgfOnphoqudNlfeP9q9uWowCO 7kO6X4zN/8GWT+w3Y80wZK9m6/AZDQQTHt05LJ8tEc/YvyEfhxvGcGvaGHHScHcEfYXP ksjw== 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=4Nb8DNkQq34GYhPUpCdC3NaYe2xGmxMJ4k6J9TBl/Sk=; b=D9DWpf49+lC0GKygldwEzL/JQXE65b50Rh2TEoRJR45Ss3XL2dmvjDyUMhNShT61Jy dHAUqsRQ6jzh+OjOsS23ztcilttnfAQ/zng4vJ5HtWxiZ00XZmQgynw6sZ3VJmwKFkns Rgjo1Pc1/T29a4mllmFwyDhrfa3iIstNJvg9uwZz2UY1svYlE8mVJN/rnCRrLB/dhgKJ ylX2+DjYqfygGLwCVUbEp2ka2F6sR9TD/j5CMG4dBxfk6BmWgYR/KD0aaqjV7OL/6dPW /aVDJNVVskSCmD6crZ9kVo1pfgO2BARgCo/656rVBZfxWYZkQr2grWMcP6q+0l+B4Vff RzWg== X-Gm-Message-State: APjAAAVN4N56dHHxKTTUE5Uc7LeKLjWhwzp68OUjFaVOaKeuN6ZKdpHq vBlKyilGehP1pGkRBMSYato= X-Google-Smtp-Source: APXvYqzcg7LQeWFKoG160wuoPTeqS00FYE1lcWVpX1SWLoKQdhRUktWhtOvHIcEhrm5aMs941yu6EA== X-Received: by 2002:a17:902:900a:: with SMTP id a10mr87918117plp.281.1563985694527; Wed, 24 Jul 2019 09:28:14 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q126sm2925552pfb.56.2019.07.24.09.28.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 09:28:14 -0700 (PDT) Date: Wed, 24 Jul 2019 09:28:12 -0700 From: Stephen Hemminger To: Anatoly Burakov Cc: dev@dpdk.org, john.mcnamara@intel.com, thomas@monjalon.net Message-ID: <20190724092812.069d9049@hermes.lan> In-Reply-To: <1862ad94e15a61121aea75a2933dc8a44bb12623.1563982007.git.anatoly.burakov@intel.com> References: <1862ad94e15a61121aea75a2933dc8a44bb12623.1563982007.git.anatoly.burakov@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 2/2] usertools/devbind: check if module is loaded before binding X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 Wed, 24 Jul 2019 16:34:44 +0100 Anatoly Burakov wrote: > +# check if a specific kernel module is loaded > +def module_is_loaded(module): > + # Get list of sysfs modules (both built-in and dynamically loaded) > + sysfs_path = '/sys/module/' > + > + # Get the list of directories in sysfs_path > + sysfs_mods = [os.path.join(sysfs_path, o) for o > + in os.listdir(sysfs_path) > + if os.path.isdir(os.path.join(sysfs_path, o))] > + > + # get module names > + sysfs_mods = [os.path.basename(a) for a in sysfs_mods] > + > + # special case for vfio_pci (module is named vfio-pci, > + # but its .ko is named vfio_pci) > + sysfs_mods = [a if a != 'vfio_pci' else 'vfio-pci' for a in sysfs_mods] > + > + return module in sysfs_mods > + You could just check if the one module exist rather than getting full list. Maybe vfio-pci should be renamed vfil_pci earlier in the code.