From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SPHN2-0007mE-5u for mharc-grub-devel@gnu.org; Tue, 01 May 2012 14:00:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPHMu-0007lx-Ks for grub-devel@gnu.org; Tue, 01 May 2012 14:00:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPHMr-0004bw-K5 for grub-devel@gnu.org; Tue, 01 May 2012 14:00:08 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:44099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPHMr-0004Rw-8Y for grub-devel@gnu.org; Tue, 01 May 2012 14:00:05 -0400 Received: by werj55 with SMTP id j55so3368837wer.0 for ; Tue, 01 May 2012 11:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; bh=OEV/BNgYiCHxpmzWpwIcBXyPJbknwGq8AfVKnlh+mR4=; b=Ga+M/IkgbTuAz6p3I3EyZAS9QTWGhQcp17oqZtGVYKRKf0Uyh6aj+Rl3SV4mG7f9s/ RrLMLU+/3PSaySuMAarEjSqQmWfm34ETawesZh+tTXPiHgUIF6xxVNdMQm5yAzq8Qm7+ 0FMSR//ihcdl1MyKJ7UlF4R+et0+glQlJiyVM5P+iAb+1bnmwGsaMhBKbVzQ/XeSzk7O wGmlgb4JCXp+wuaIPLbUuuWWtjgcWH8zUwlC9UneAr9HCBUv1rgHj8omn7Pcq+HibyaG 8qWjmABbTKGcmYTBhmETm7h97wk4WdKSL7OoiccAlZsUGD4y/jpHELFnhgKaY07TQaDi MaNg== Received: by 10.180.85.70 with SMTP id f6mr7034553wiz.5.1335895202084; Tue, 01 May 2012 11:00:02 -0700 (PDT) Received: from debian.x201.phnet (9-234.197-178.cust.bluewin.ch. [178.197.234.9]) by mx.google.com with ESMTPS id fn2sm60141890wib.0.2012.05.01.10.59.58 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 01 May 2012 11:00:00 -0700 (PDT) Message-ID: <4FA02495.7040405@gmail.com> Date: Tue, 01 May 2012 19:59:49 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120329 Icedove/10.0.3 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: ReiserFS reading performance patch References: In-Reply-To: X-Enigmail-Version: 1.4.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigA70293E354125D6030A3F05B" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.169 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 18:00:15 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA70293E354125D6030A3F05B Content-Type: multipart/mixed; boundary="------------030709040004040801060200" This is a multi-part message in MIME format. --------------030709040004040801060200 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 27.04.2012 16:05, Albert Zeyer wrote: > Hi, > > A while ago, I improved the grub-mount patches a bit. Mostly: You've based your work on abandonded branch. All grub-mount parts were merged back in trunk a long time ago. At least half of the work you've done was unnecessary with newer version. > * Write a simplified compile.py script. Custom compile scripts are likely to break often. If there were any problem in our compile scripts for your platform it's better to announce it here. > * Remove nested functions. They don't work on Mac because of stack > execution protection. As I said, your approach isn't just ugly it results in bugs. > * Improve ReiserFS reading performance. I wrote reiserfs caching a long time ago but it didn'tmake any sizeable difference. As for making offset search a logarithmic, here is a patch by few simple modifications of get_item. --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------030709040004040801060200 Content-Type: text/x-diff; name="reiserspeed.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="reiserspeed.diff" =3D=3D=3D modified file 'grub-core/Makefile.am' --- grub-core/Makefile.am 2012-02-29 14:08:08 +0000 +++ grub-core/Makefile.am 2012-05-01 14:19:39 +0000 @@ -96,6 +96,7 @@ KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/efi/time.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/i386/pit.h +KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/pci.h endif =20 if COND_i386_coreboot @@ -126,6 +127,7 @@ KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/efi/time.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/i386/pit.h +KERNEL_HEADER_FILES +=3D $(top_srcdir)/include/grub/pci.h endif =20 if COND_ia64_efi =3D=3D=3D modified file 'grub-core/Makefile.core.def' --- grub-core/Makefile.core.def 2012-04-01 19:35:18 +0000 +++ grub-core/Makefile.core.def 2012-05-01 13:59:06 +0000 @@ -139,11 +139,13 @@ =20 i386_efi =3D kern/i386/tsc.c; i386_efi =3D kern/i386/efi/init.c; + i386_efi =3D bus/pci.c; =20 x86_64_efi =3D kern/i386/tsc.c; x86_64_efi =3D kern/x86_64/dl.c; x86_64_efi =3D kern/x86_64/efi/callwrap.S; x86_64_efi =3D kern/i386/efi/init.c; + x86_64_efi =3D bus/pci.c; =20 ia64_efi =3D kern/ia64/efi/startup.S; ia64_efi =3D kern/ia64/efi/init.c; @@ -475,8 +477,6 @@ common =3D bus/pci.c; =20 enable =3D i386_pc; - enable =3D i386_efi; - enable =3D x86_64_efi; enable =3D i386_ieee1275; enable =3D i386_coreboot; enable =3D i386_multiboot; =3D=3D=3D modified file 'grub-core/commands/legacycfg.c' --- grub-core/commands/legacycfg.c 2012-03-06 13:11:10 +0000 +++ grub-core/commands/legacycfg.c 2012-05-01 12:23:30 +0000 @@ -123,7 +123,8 @@ return grub_errno; } args[0] =3D oldname; - grub_normal_add_menu_entry (1, args, NULL, NULL, NULL, NULL, NULL, + grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy", + NULL, NULL, entrysrc, 0); grub_free (args); entrysrc[0] =3D 0; =3D=3D=3D modified file 'grub-core/commands/menuentry.c' --- grub-core/commands/menuentry.c 2012-03-19 09:56:43 +0000 +++ grub-core/commands/menuentry.c 2012-05-01 12:22:47 +0000 @@ -37,6 +37,8 @@ {"source", 4, 0, N_("Use STRING as menu entry body."), N_("STRING"), ARG_TYPE_STRING= }, {"id", 0, 0, N_("Menu entry identifier."), N_("STRING"), ARG_TYPE_ST= RING}, + {"unrestricted", 0, 0, N_("This entry can be booted by any user."), + 0, ARG_TYPE_NONE}, {0, 0, 0, 0, 0, 0} }; =20 @@ -254,6 +256,7 @@ char *prefix; unsigned len; grub_err_t r; + const char *users; =20 if (! argc) return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing arguments"); @@ -264,12 +267,19 @@ if (! ctxt->state[3].set && ! ctxt->script) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition")= ; =20 + if (ctxt->state[1].set) + users =3D ctxt->state[1].arg; + else if (ctxt->state[5].set) + users =3D NULL; + else + users =3D ""; + if (! ctxt->script) return grub_normal_add_menu_entry (argc, (const char **) args, (ctxt->state[0].set ? ctxt->state[0].args : NULL), ctxt->state[4].arg, - ctxt->state[1].arg, + users, ctxt->state[2].arg, 0, ctxt->state[3].arg, ctxt->extcmd->cmd->name[0] =3D=3D 's'); @@ -287,7 +297,7 @@ =20 r =3D grub_normal_add_menu_entry (argc - 1, (const char **) args, ctxt->state[0].args, ctxt->state[4].arg, - ctxt->state[1].arg, + users, ctxt->state[2].arg, prefix, src + 1, ctxt->extcmd->cmd->name[0] =3D=3D 's'); =20 =3D=3D=3D modified file 'grub-core/fs/reiserfs.c' --- grub-core/fs/reiserfs.c 2012-02-27 20:36:58 +0000 +++ grub-core/fs/reiserfs.c 2012-05-01 15:44:15 +0000 @@ -468,7 +468,7 @@ static grub_err_t grub_reiserfs_get_item (struct grub_reiserfs_data *data, const struct grub_reiserfs_key *key, - struct grub_fshelp_node *item) + struct grub_fshelp_node *item, int exact) { grub_uint32_t block_number; struct grub_reiserfs_block_header *block_header =3D 0; @@ -581,30 +581,47 @@ item_headers =3D (struct grub_reiserfs_item_header *) (block_header + 1);= for (i =3D 0; - i < item_count - && (grub_reiserfs_compare_keys (key, &(item_headers[i].= key)) - !=3D 0); + i < item_count; i++) - { -#ifdef GRUB_REISERFS_DEBUG - if (key->directory_id =3D=3D item_headers[i].key.directory= _id && \ - key->object_id =3D=3D item_headers[i].key.object_id) - grub_printf("C"); - else - grub_printf(" "); - grub_printf(" %03d/%03d ", i + 1, item_count); - grub_reiserfs_print_key (&(item_headers[i].key)); -#endif - } - if (i < item_count) - block_key =3D &(item_headers[i].key); + { + int val; + val =3D grub_reiserfs_compare_keys (key, &(item_headers[i].key));= + if (val =3D=3D 0) + { + block_key =3D &(item_headers[i].key); + break; + } + if (val < 0 && exact) + break; + if (val < 0) + { + if (i =3D=3D 0) + { + grub_error (GRUB_ERR_READ_ERROR, "unexpected btree node"); + goto fail; + } + i--; + block_key =3D &(item_headers[i].key); + break; + } + } + if (!exact && i =3D=3D item_count) + { + if (i =3D=3D 0) + { + grub_error (GRUB_ERR_READ_ERROR, "unexpected btree node"); + goto fail; + } + i--; + block_key =3D &(item_headers[i].key); + } } } while (current_level > 1); =20 item->data =3D data; =20 - if (i =3D=3D item_count || grub_reiserfs_compare_keys (key, block_key)= ) + if (!block_key) { item->block_number =3D 0; item->block_position =3D 0; @@ -654,7 +671,7 @@ grub_reiserfs_set_key_type (&key, GRUB_REISERFS_DIRECT, grub_reiserfs_get_key_version (&key)); =20 - if (grub_reiserfs_get_item (node->data, &key, &found) !=3D GRUB_ERR_NO= NE) + if (grub_reiserfs_get_item (node->data, &key, &found, 1) !=3D GRUB_ERR= _NONE) goto fail; =20 if (found.block_number =3D=3D 0) @@ -797,7 +814,7 @@ if (! entry_item) goto fail; =20 - if (grub_reiserfs_get_item (data, &entry_key, entry_item) + if (grub_reiserfs_get_item (data, &entry_key, entry_item, = 1) !=3D GRUB_ERR_NONE) { grub_free (entry_item); @@ -816,7 +833,7 @@ grub_reiserfs_set_key_offset (&entry_key, 0); grub_reiserfs_set_key_type (&entry_key, GRUB_REISERFS_= STAT, 2); - if (grub_reiserfs_get_item (data, &entry_key, entry_it= em) + if (grub_reiserfs_get_item (data, &entry_key, entry_it= em, 1) !=3D GRUB_ERR_NONE) { grub_free (entry_item); @@ -959,7 +976,7 @@ grub_reiserfs_set_key_offset (&(item_headers[block_position].key),= next_offset); if (grub_reiserfs_get_item (data, &(item_headers[block_position].k= ey), - &directory_item) !=3D GRUB_ERR_NONE) + &directory_item, 1) !=3D GRUB_ERR_NONE= ) goto fail; block_number =3D directory_item.block_number; block_position =3D directory_item.block_position; @@ -1001,7 +1018,7 @@ key.u.v2.offset_type =3D 0; grub_reiserfs_set_key_type (&key, GRUB_REISERFS_DIRECTORY, 2); grub_reiserfs_set_key_offset (&key, 1); - if (grub_reiserfs_get_item (data, &key, &root) !=3D GRUB_ERR_NONE) + if (grub_reiserfs_get_item (data, &key, &root, 1) !=3D GRUB_ERR_NONE) goto fail; if (root.block_number =3D=3D 0) { @@ -1017,7 +1034,7 @@ key.object_id =3D found->header.key.object_id; grub_reiserfs_set_key_type (&key, GRUB_REISERFS_STAT, 2); grub_reiserfs_set_key_offset (&key, 0); - if (grub_reiserfs_get_item (data, &key, &info) !=3D GRUB_ERR_NONE) + if (grub_reiserfs_get_item (data, &key, &info, 1) !=3D GRUB_ERR_NONE) goto fail; if (info.block_number =3D=3D 0) { @@ -1097,11 +1114,27 @@ (unsigned long long) final_position, (unsigned long long) (final_position - initial_position), (unsigned long) len); + + grub_reiserfs_set_key_offset (&key, initial_position + 1); + + if (grub_reiserfs_get_item (data, &key, &found, 0) !=3D GRUB_ERR_NONE)= + goto fail; + + if (found.block_number =3D=3D 0) + { + grub_error (GRUB_ERR_READ_ERROR, "offset %lld not found", + (unsigned long long) initial_position); + goto fail; + } + + current_key_offset =3D grub_reiserfs_get_key_offset (&found.header.key= ); + current_position =3D current_key_offset - 1; + while (current_position < final_position) { grub_reiserfs_set_key_offset (&key, current_key_offset); =20 - if (grub_reiserfs_get_item (data, &key, &found) !=3D GRUB_ERR_NONE= ) + if (grub_reiserfs_get_item (data, &key, &found, 1) !=3D GRUB_ERR_N= ONE) goto fail; if (found.block_number =3D=3D 0) goto fail; @@ -1245,7 +1278,7 @@ =20 fail: grub_free (indirect_block_ptr); - return 0; + return -1; } =20 /* Close the file FILE. */ @@ -1296,7 +1329,7 @@ root_key.u.v2.offset_type =3D 0; grub_reiserfs_set_key_type (&root_key, GRUB_REISERFS_DIRECTORY, 2); grub_reiserfs_set_key_offset (&root_key, 1); - if (grub_reiserfs_get_item (data, &root_key, &root) !=3D GRUB_ERR_NONE= ) + if (grub_reiserfs_get_item (data, &root_key, &root, 1) !=3D GRUB_ERR_N= ONE) goto fail; if (root.block_number =3D=3D 0) { =3D=3D=3D modified file 'grub-core/kern/efi/mm.c' --- grub-core/kern/efi/mm.c 2011-05-15 09:22:59 +0000 +++ grub-core/kern/efi/mm.c 2012-04-28 16:11:38 +0000 @@ -22,6 +22,10 @@ #include #include =20 +#if defined (__i386__) || defined (__x86_64__) +#include +#endif + #define NEXT_MEMORY_DESCRIPTOR(desc, size) \ ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size))) =20 @@ -103,6 +107,74 @@ efi_call_2 (b->free_pages, address, pages); } =20 +#if defined (__i386__) || defined (__x86_64__) + +static grub_uint8_t +find_cap (grub_pci_device_t dev, grub_uint8_t cap) +{ + grub_uint8_t pos =3D 0x34; + int ttl =3D 48; + + while (ttl--) + { + grub_uint8_t id; + grub_pci_address_t addr; + + addr =3D grub_pci_make_address (dev, pos); + pos =3D grub_pci_read_byte (addr); + if (pos < 0x40) + break; + + pos &=3D ~3; + + addr =3D grub_pci_make_address (dev, pos); =20 + id =3D grub_pci_read_byte (addr); + + if (id =3D=3D 0xff) + break; + =20 + if (id =3D=3D cap) + return pos; + pos++; + } + return 0; +} + +static void +stop_broadcom (void) +{ + auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, + grub_pci_id_t pciid); + + int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, + grub_pci_id_t pciid) + { + grub_pci_address_t addr; + grub_uint8_t cap; + grub_uint16_t pm_state; + + if ((pciid & 0xffff) !=3D GRUB_PCI_VENDOR_BROADCOM) + return 0; + + addr =3D grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); + if (grub_pci_read (addr) >> 24 !=3D GRUB_PCI_CLASS_NETWORK) + return 0; + cap =3D find_cap (dev, GRUB_PCI_CAP_POWER_MANAGEMENT); + if (!cap) + return 0; + addr =3D grub_pci_make_address (dev, cap + 4); + pm_state =3D grub_pci_read_word (addr); + pm_state =3D pm_state | 0x03; + grub_pci_write_word (addr, pm_state); + grub_pci_read_word (addr); + return 0; + } + + grub_pci_iterate (find_card); +} + +#endif + grub_err_t grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outb= uf, grub_efi_uintn_t *map_key, @@ -112,6 +184,14 @@ grub_efi_boot_services_t *b; grub_efi_status_t status; =20 +#if defined (__i386__) || defined (__x86_64__) + const grub_uint16_t apple[] =3D { 'A', 'p', 'p', 'l', 'e' }; + int is_apple; + + is_apple =3D (grub_memcmp (grub_efi_system_table->firmware_vendor, + apple, sizeof (apple)) =3D=3D 0); +#endif + if (grub_efi_get_memory_map (&finish_mmap_size, finish_mmap_buf, &fini= sh_key, &finish_desc_size, &finish_desc_version) < 0) return grub_error (GRUB_ERR_IO, "couldn't retrieve memory map"); @@ -145,6 +225,11 @@ if (efi_desc_version) *efi_desc_version =3D finish_desc_version; =20 +#if defined (__i386__) || defined (__x86_64__) + if (is_apple) + stop_broadcom (); +#endif + return GRUB_ERR_NONE; } =20 =3D=3D=3D modified file 'grub-core/lib/relocator.c' --- grub-core/lib/relocator.c 2012-04-13 14:55:20 +0000 +++ grub-core/lib/relocator.c 2012-05-01 12:30:35 +0000 @@ -368,7 +368,7 @@ GRUB_MM_ALIGN); h->size =3D ((subchu->start + subchu->size + GRUB_MM_ALIGN - 1) / GRUB_MM_ALI= GN) - - (subchu->start / GRUB_MM_ALIGN) - 1; + - (subchu->start / GRUB_MM_ALIGN); h->next =3D h; h->magic =3D GRUB_MM_ALLOC_MAGIC; grub_free (h + 1); =3D=3D=3D modified file 'include/grub/pci.h' --- include/grub/pci.h 2011-10-01 19:37:02 +0000 +++ include/grub/pci.h 2012-04-28 15:59:34 +0000 @@ -81,6 +81,19 @@ #define GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT 9 #define GRUB_PCI_STATUS_DEVSEL_TIMING_MASK 0x0600 #define GRUB_PCI_CLASS_SUBCLASS_VGA 0x0300 +enum + { + GRUB_PCI_CLASS_NETWORK =3D 0x02 + }; +enum + { + GRUB_PCI_CAP_POWER_MANAGEMENT =3D 0x01 + }; + +enum + { + GRUB_PCI_VENDOR_BROADCOM =3D 0x14e4 + }; =20 #ifndef ASM_FILE typedef grub_uint32_t grub_pci_id_t; =3D=3D=3D modified file 'util/grub.d/00_header.in' --- util/grub.d/00_header.in 2012-03-04 13:55:13 +0000 +++ util/grub.d/00_header.in 2012-04-29 19:49:48 +0000 @@ -278,9 +278,15 @@ else verbose=3D" --verbose" fi + timeout=3D"$2" + if [ "x${timeout}" =3D "x0" ]; then + timeout=3D10 + fi =20 cat << EOF if sleep$verbose --interruptible ${1} ; then - set timeout=3D${2} + set timeout=3D0 +else + set timeout=3D${timeout} fi EOF else --------------030709040004040801060200-- --------------enigA70293E354125D6030A3F05B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAk+gJJcACgkQNak7dOguQgl2zwD9F2RJQmcOnIU9hbhOJ6fYm26u KfDdTPbhbi3ltbHaAAMA/iEn6DK95qHGBt3O1BZggOTgHgRW1lGIGEm/HUnZvCaK =giGR -----END PGP SIGNATURE----- --------------enigA70293E354125D6030A3F05B--