From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id B4B4B343C for ; Thu, 9 Aug 2018 19:03:51 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id k21-v6so3122261pff.11 for ; Thu, 09 Aug 2018 10:03:51 -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=2cJeFm8t0zRfz4q7hZsMiA7//mlnM+vzs7roVOX/h8o=; b=MlQg9as3yHS7kdIGPmePMBVGZN2n2BRpPWqR2VXgV2PmqaAp2zCkylhfUUy9OvGWXe n80sorpco4XFEvq68hDGXWAv2qSgDSjZcEr5g1DewzmQ3hwp5F12+ufmVvuyxi4BuiKY nWgkaWrWgdGnd2S7l6gtB/CnhqZh7Dxa3WQtve52R4RGijsc0qvYQ3sBaJxwxWDXJQdT EOYitkKMlAGCD/ZW7NlJZx1R2LN9vJbWgyj/O5sI0a/8M+Ko9k8XtXKQG2vyecUjOwRM 0/cHgDCL1T/JMKHSQO707IVrHWedKaNbCDYjsq+E/r9YPdkFxY+YfAldW1cUsBgWBfOB LsYg== 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=2cJeFm8t0zRfz4q7hZsMiA7//mlnM+vzs7roVOX/h8o=; b=iHkaas27/NJVEPpHtkLZaLeE8f3pUWg0B3IFOIT4O07Fav0yPL/Cu9+AJxn0nhSSf8 dsJg5ZkF8uBfEZ4v80AYg0IJUgpAw9z1DkfUSHIPokZyXnQXBooPR3DAXb5sBn8K+hLQ KFntl4wan4XbLtccZY+Id+wjLCAYzcI1IZbLeJO0UvldUGHxEM3qBcSXmI+4u7WVFQmD eDz/GpnuHFo6+ujv75XsJQxsre4TyFhZUb4clktg3CFSB82KXZTDgURXfWtHR0pzZiu7 /Z3IUHOTu/0lhxWULaN89ZVv3jdSVAlPq9X75ZaN7WpSQD0eMDCdXDhlWGKwNxC7PHP5 2WWA== X-Gm-Message-State: AOUpUlELzL43l8K2iqLbdGdy2AhM84q7K0OJfr9RHz/p/jnm7xskSBXY J5PvMSSPSucRZg07aULo0bqs1w== X-Google-Smtp-Source: AA+uWPxu2bZjYhgKlVvZBWKvH3sgm2C4S9a6W/8DKKrBHQnXITTRrGCWrwdh5hcpsEd28moLGBniWQ== X-Received: by 2002:a63:e14a:: with SMTP id h10-v6mr3028918pgk.358.1533834230863; Thu, 09 Aug 2018 10:03:50 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id a191-v6sm10278083pge.45.2018.08.09.10.03.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 10:03:50 -0700 (PDT) Date: Thu, 9 Aug 2018 10:03:44 -0700 From: Stephen Hemminger To: Drocula Cc: maxime.coquelin@redhat.com, dev@dpdk.org Message-ID: <20180809100344.15af7e9c@xeon-e3> In-Reply-To: <1533494497-16253-1-git-send-email-quzeyao@gmail.com> References: <1533494497-16253-1-git-send-email-quzeyao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] bus/pci: check if 5-level paging is enabled when testing IOMMU address width 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: , X-List-Received-Date: Thu, 09 Aug 2018 17:03:52 -0000 Thanks for the patch, there are some minor style/cleanups that could be done. > #if defined(RTE_ARCH_X86) Isn't this going to apply to 64 bit only? > +/* > + * Try to detect whether the system uses 5-level page table. > + */ > +static bool > +system_uses_PML5(void) > +{ > + void *page_4k, *mask = (void *)0xf0000000000000; Magic constants expressed like this seem wrong. Why not use shift to make it obvious. Also, you are assuming a particular layout of memory on Linux which might be problematic. Plus if there is already some memory in use there, it won't work. > + page_4k = mmap(mask, 4096, PROT_READ | PROT_WRITE, > + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); Since you are probing maybe MAP_FIXED is what you want. > + > + if (page_4k == (void *) -1) > + return false; Use MMAP_FAILED here. > + munmap(page_4k, 4096); > + > + if ((unsigned long)page_4k & (unsigned long)mask) > + return true; > + return false; Wouldn't this work the same for what you expect? return page_4k == mask; I.e you expect kernel to put page where you want.