From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1m3YKM-0002Rj-GP for mharc-grub-devel@gnu.org; Wed, 14 Jul 2021 02:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3YKL-0002Ra-Gd for grub-devel@gnu.org; Wed, 14 Jul 2021 02:25:01 -0400 Received: from de-smtp-delivery-102.mimecast.com ([194.104.109.102]:38245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3YKJ-00008D-EL for grub-devel@gnu.org; Wed, 14 Jul 2021 02:25:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1626243897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yyvkhqbgu1oC5g1z5LhyXisAupk9R4GslMnpzWYM6lc=; b=BeEEnJvlWyMrxuw3rSu0hjDivvdOTwE/Slm5e3QStmwWpQf6z/8YmuiEVSjA9zHjebnSHV ygFQ5HGimyU3h+D34yxqhEB8fceOB0iaj1Z3/gmWvvY1RsRbbO5ECBmUTGh6xyJq6ETcA3 pM6WRztZmLeK9T/0+3TiLuOwgpQXMvM= Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2051.outbound.protection.outlook.com [104.47.4.51]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-11-aEkU63gWMce5hDJfWMJrxw-1; Wed, 14 Jul 2021 08:24:56 +0200 X-MC-Unique: aEkU63gWMce5hDJfWMJrxw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQuVaiaNOWKDYy9JoGo63ViESwzBD6R7avYn4FTf5TB67VSIGNOkYxVn2HgyG7gproFDXVwjMZONCZaQJfo372Qx8eK1BQVyHtoWSkDZG20/1Agy5vMuRx953tX4TsIFkQ2KmfrC94qiO4AUyBt02AKD+Gs/gMzcUDWxJKa4mihI87dXBhZcwvt536S0kLpWQpExKZSjHi5w852L5W6a1DSQeH7Sz03b7XqcsckzTe2SRReyQxgQ/6uG/f/y9Fqd8JeyfzyIof1i8k/5JAs14On6as5zs4smBM9y9FhBd9nAZH3z8UDW+Uu5zWXlxEg+sj4NIWQeCq4aI2/IhOvHBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nBMTo45UfDtElFJRJhdcJidGoIucivQbdSVnK5YaE5w=; b=QK9Rz/Zy5/KQdzQ0FNErX7zpesBVBXO5d4mG4UBAJYLyDS4k2Fix4Fs88eMNzfOu3sr/YVIL2jRG+JOoia2smxl678jnKe35KPk8z1c9A8ETSHHpI3mDBjdo72//9IAIFRkSxyyUi1zZpnRRZissyFVRKXbS0Erw0oP7NUKkcyQ0EnQqM6lEtD0c+AYey4oq0V/6MFOtMeFcOn4hDnNTVrno7wWvAV3r9/00DEvgLbOlLQWPzWt+ADZlyExCChc3rY+7ifksT/MpkE58CZEEmH4OmwcPzm4uROz32N1DePGFv9c6u5uPJZmAA+kdHxOj/moIfYe/61OoKjFbRr76Fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: suse.cz; dkim=none (message not signed) header.d=none;suse.cz; dmarc=none action=none header.from=suse.com; Received: from DU2PR04MB8648.eurprd04.prod.outlook.com (2603:10a6:10:2df::21) by DU2PR04MB8840.eurprd04.prod.outlook.com (2603:10a6:10:2e3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Wed, 14 Jul 2021 06:24:55 +0000 Received: from DU2PR04MB8648.eurprd04.prod.outlook.com ([fe80::245b:a7da:fcc:25a1]) by DU2PR04MB8648.eurprd04.prod.outlook.com ([fe80::245b:a7da:fcc:25a1%4]) with mapi id 15.20.4308.027; Wed, 14 Jul 2021 06:24:55 +0000 Date: Wed, 14 Jul 2021 14:24:49 +0800 From: Michael Chang To: Petr Vorel CC: Paul Menzel , Jeff Mahoney , Daniel Kiper , Mike Gilbert , The development of GNU GRUB Subject: Re: [PATCH 2/2] grub2: use stat instead of udevadm for partition lookup Message-ID: <20210714062449.GA18534@mercury> References: <20210708155558.26466-1-pvorel@suse.cz> <20210708155558.26466-3-pvorel@suse.cz> <33f16d1e-162c-6eb1-b0d0-fa69d4a2dbe4@molgen.mpg.de> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: HK2PR03CA0061.apcprd03.prod.outlook.com (2603:1096:202:17::31) To DU2PR04MB8648.eurprd04.prod.outlook.com (2603:10a6:10:2df::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost (36.226.47.79) by HK2PR03CA0061.apcprd03.prod.outlook.com (2603:1096:202:17::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.10 via Frontend Transport; Wed, 14 Jul 2021 06:24:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: abca8ec7-92e5-4522-3ee7-08d946901892 X-MS-TrafficTypeDiagnostic: DU2PR04MB8840: X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vNPd1OHs25NSAxRIq08ZNB6gVODAOGYamzYQeSXoFp6cAujZX3A2Z8CfvsZVJ4CeVQrH1vBqhZrAvoFsIqzSlZL0cuw6UJHd8Lqrcgr/1yIbuDE4Ga1t429vJc+xi6EufAwLC6pfjiNaw0Cq7qmfVCHwk/YaprFcJxYHQtxF2obAvsrTKzVzDwQINuu8IFHa2a2ytM1YsD30+AhzAE7hOrWsSAXOPzISaJYgpCEr7uv2PfnD7betdxy4nNKKQ2f5urAhnBPAgpvlRkP9mMhqE/vfej9dZ87FAL3PuqGMQOplN/XDl8mOoj2bNdgE4Zmk+ThhWZ0W3n2mphUOYs4pJ2s+yu7T9XbWnj4/7kcBXs9y7wekoLXJ3dfLfvYOlbmoEcfMd8MFTJrjgwxOyJOOD5maTWvCny5co2261tTdo1UbdkvsQu3v6RqQaquZNi7A0rWfVzzxiqtaC+MUie2BFsKFeRROLDmwvb8Ey90C6DP6NGn4fSFsugm1BNdSQrYB76vJnIo/mcyqPgC23cbNPz/CMByGKWQZREKtzMWyBCSsBsKRUItdekkGspeiGzl3sH0QYvCPDVxfNY+KPCgUOXF6gCPQ8duFhAtW7ELRopdOXdafFIa+gzvVTuf8U68FKKgx5vX3IjtzdUysonde8g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8648.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(7916004)(346002)(39850400004)(396003)(136003)(366004)(376002)(4326008)(478600001)(86362001)(26005)(8676002)(66946007)(6486002)(9686003)(38100700002)(54906003)(66476007)(956004)(66556008)(5660300002)(6496006)(8936002)(6666004)(6916009)(2906002)(316002)(33716001)(1076003)(33656002)(83380400001)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Ant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ETyQOxb6Q3zGr6Jt1wlgPEa25sZXb9EPoxqmXs8Z5ympZYM8wa?= =?us-ascii?Q?reGw6yz67gp5tSXJc1tLcC62feJRGNKZX2Y6ixSMGJVDZU6gnyKMDcmcwOnh?= =?us-ascii?Q?NXy7PndhD593jvtOPy22ypoPlsETIOnHgldkgCVktu0R4UVuZwAde6Qtz5Aa?= =?us-ascii?Q?NBucdh/SHwvcpwN/1vsF5lrkf7WkY9NiRQkBx3FHuFqU3nsQqFRodB9kK4hw?= =?us-ascii?Q?wMgAR82bGY59sjkZiNoiiCr0G9NQl138l5Ufhm099WEjBsNrxq+9QG+fCXe6?= =?us-ascii?Q?Ewr7GtA7yCTtZh9gDfsoGcRFRoV7NwsH1YEUzL/V/RwmaxiBMycb93pvbJi0?= =?us-ascii?Q?ktPppRybBYRaYD2y/8BsTipSO6kl6zO57rXs0K3n8MlK8zWwbuSU3IycLEQd?= =?us-ascii?Q?ac10B30Fm7Y3mlWYx+Wkd2tUBGRpXhl3pip1hsb7cZlJFQizFglsmsO12snP?= =?us-ascii?Q?S+hNayv8b7YpSXNND5i0LW+i?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: abca8ec7-92e5-4522-3ee7-08d946901892 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8648.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2021 06:24:55.2113 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1ILtBTS+hwofMtdGGvVsex9w4VaGDZOQQKf6gE2dVL9jc7px7tVT3muglPpsPSib X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8840 Received-SPF: pass client-ip=194.104.109.102; envelope-from=mchang@suse.com; helo=de-smtp-delivery-102.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2021 06:25:01 -0000 On Tue, Jul 13, 2021 at 12:52:12PM +0200, Petr Vorel wrote: > Hi Paul, >=20 > > Dear Petr, dear Jeff, >=20 >=20 > > Am 08.07.21 um 17:55 schrieb Petr Vorel: > > > From: Jeff Mahoney >=20 > > > sysfs_partition_path calls udevadm to resolve the sysfs path for > > > a block device. That can be accomplished by stating the device node > > > and using the major/minor to follow the symlinks in /sys/dev/block/. >=20 > > > This cuts the execution time of grub2-mkconfig from 10s to 2s on > > > my system. >=20 > > Petr, where you able to reproduce this issue? > No, I'm sorry, I haven't even tried, because accessing sysfs seems to me = as a > quickest way anyway. But agree that we drag this patch in opensuse from 2= 017 > (for 2.02~rc1), it might not be relevant for nowadays systems. >=20 > > Could the specifications of Jeff=E2=80=99s system be added to the commi= t message? > Jeff, Michael, could you verify if it's still relevant? It is still relevant per my test, although not as considerable as Jeff's system. I was using openSUSE Tumbleweed, pretty much all defaults and simple, btrfs as root file system without any abstraction disks (lvm, mdadm and encryption). NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 663M 0 rom =20 vda 253:0 0 20G 0 disk=20 vda1 253:1 0 1.4G 0 part [SWAP] vda2 253:2 0 18.6G 0 part / The output of `time grub2-mkconfig -o /boot/grub2/grub.cfg` with the patch applied. real 0m1.292s user 0m0.782s sys 0m0.427s and without real 0m2.323s user 0m1.295s sys 0m0.956s This cuts the execution to somewhere near 55%, which is pretty signifcant. Please note if testing on lvm, there wouldn't have difference on the execution time as libdevmapper is used instead of udevadm to get the partition start. Thanks, Michael >=20 > Kind regards, > Petr >=20 > > > Signed-off-by: Jeff Mahoney > > > [ pvorel: include grub/osdep/major.h ] > > > Signed-off-by: Petr Vorel > > > --- > > > grub-core/osdep/linux/hostdisk.c | 8 ++++++++ > > > 1 file changed, 8 insertions(+) >=20 > > > diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux= /hostdisk.c > > > index da62f924e..43dc4b0ba 100644 > > > --- a/grub-core/osdep/linux/hostdisk.c > > > +++ b/grub-core/osdep/linux/hostdisk.c > > > @@ -31,6 +31,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > @@ -105,6 +106,13 @@ sysfs_partition_path (const char *dev, const cha= r *entry) > > > char *buf =3D NULL; > > > size_t len =3D 0; > > > char *path =3D NULL; > > > + struct stat st; > > > + int ret; > > > + > > > + ret =3D stat(dev, &st); > > > + if (ret =3D=3D 0 && S_ISBLK(st.st_mode)) > > > + return xasprintf ("/sys/dev/block/%u:%u/%s", > > > + major (st.st_rdev), minor (st.st_rdev), entry); > > > argv[0] =3D "udevadm"; > > > argv[1] =3D "info"; >=20 > > Now the non-block device case has one stat call more executed each time= . >=20 >=20 > > Kind regards, >=20 > > Paul >=20