linux_dsm_epyc7002/drivers
Eric Dumazet 6b31a515e3 [TG3]: Avoid an expensive divide.
During an oprofile session of linux-2.6.20 on a dual opteron system, I noticed
an expensive divide was done in tg3_poll().

I am using gcc-4.1.1, so the following comment from drivers/net/tg3.c seems
over-optimistic :

/* Do not place this n-ring entries value into the tp struct itself,
  * we really want to expose these constants to GCC so that modulo et
  * al.  operations are done with shifts and masks instead of with
  * hw multiply/modulo instructions.  Another solution would be to
  * replace things like '% foo' with '& (foo - 1)'.
  */
#define TG3_RX_RCB_RING_SIZE(tp)        \
         ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ?  512 : 1024)

Assembly code before patch :
(oprofile results included)
   6434  0.0088 :ffffffff803684b9:       mov    0x6f0(%r15),%eax
    587 8.0e-04 :ffffffff803684c0:       and    $0x40000,%eax
   2170  0.0030 :ffffffff803684c5:       cmp    $0x1,%eax
                :ffffffff803684c8:       lea    0x1(%r13),%eax
                :ffffffff803684cc:       sbb    %ecx,%ecx
   2051  0.0028 :ffffffff803684ce:       xor    %edx,%edx
                :ffffffff803684d0:       and    $0x200,%ecx
     20 2.7e-05 :ffffffff803684d6:       add    $0x200,%ecx
   1986  0.0027 :ffffffff803684dc:       div    %ecx
103427  0.1410 :ffffffff803684de:       cmp    %edx,0xffffffffffffff7c(%rbp)

Assembly code after the suggested patch :

ffffffff803684b9:           mov    0x6f0(%r15),%eax
ffffffff803684c0:           and    $0x40000,%eax
ffffffff803684c5:           cmp    $0x1,%eax
ffffffff803684c8:           sbb    %eax,%eax
ffffffff803684ca:           inc    %r13d
ffffffff803684cd:           and    $0x200,%eax
ffffffff803684d2:           add    $0x1ff,%eax
ffffffff803684d7:           and    %eax,%r13d
ffffffff803684da:           cmp    %r13d,0xffffffffffffff7c(%rbp)

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Acked-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-02-08 12:38:57 -08:00
..
acorn [PATCH] getting rid of all casts of k[cmz]alloc() calls 2006-12-13 09:05:58 -08:00
acpi Pull acpica into test branch 2007-02-06 15:30:03 -05:00
amba
ata Revert "PCI: remove duplicate device id from ata_piix" 2007-02-07 16:17:27 -08:00
atm [PATCH] horizon.c: missing __devinit 2007-01-23 11:09:49 -08:00
base Driver Core: Increase the default timeout value of the firmware subsystem 2007-02-07 10:37:14 -08:00
block [PATCH] Fix BUG at drivers/scsi/scsi_lib.c:1118 caused by "pktsetup dvd /dev/sr0" 2007-01-05 23:55:22 -08:00
bluetooth [Bluetooth] Correct SCO buffer for Broadcom based Dell laptops 2007-01-09 00:29:59 -08:00
cdrom [PATCH] cdrom: set default timeout to 7 seconds 2007-01-03 17:32:54 -08:00
char Merge master.kernel.org:/pub/scm/linux/kernel/git/paulus/powerpc 2007-02-08 10:04:20 -08:00
clocksource [PATCH] clocksource: small cleanup 2006-12-10 09:57:22 -08:00
connector [PATCH] connector: some fixes for ia64 unaligned access errors 2007-01-05 23:55:29 -08:00
cpufreq [CPUFREQ] check sysfs_create_link return value 2007-01-29 00:06:27 -05:00
crypto [S390] Support for s390 Pseudo Random Number Generator 2007-02-05 21:18:22 +01:00
dio
dma
edac
eisa
fc4 [PATCH] getting rid of all casts of k[cmz]alloc() calls 2006-12-13 09:05:58 -08:00
firmware ACPICA: Remove duplicate table definitions (non-conflicting), cont 2007-02-02 21:14:29 -05:00
hid HID: move away from DEBUG defines in favor of CONFIG_HID_DEBUG 2007-02-05 10:00:45 +01:00
hwmon hwmon/w83793: Hide invalid VID readings 2007-01-18 22:14:24 +01:00
i2c USB: <linux/usb_ch9.h> becomes <linux/usb/ch9.h> 2007-02-07 15:44:32 -08:00
ide Merge master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6 2007-02-07 19:32:36 -08:00
ieee1394 ieee1394: sbp2: fix probing of some DVD-ROM/RWs 2007-01-10 20:24:42 +01:00
infiniband Network: convert network devices to use struct device instead of class_device 2007-02-07 10:37:11 -08:00
input SERIO: add the sysfs driver name to all modules 2007-02-07 10:37:12 -08:00
isdn [PATCH] Gigaset ISDN driver error handling fixes 2007-01-26 13:50:58 -08:00
kvm [PATCH] KVM: fix lockup on 32-bit intel hosts with nx disabled in the bios 2007-02-01 16:22:41 -08:00
leds [PATCH] Fix leds-s3c24xx hardware.h reference 2007-01-05 23:55:21 -08:00
macintosh [POWERPC] windfarm: don't die on suspend thread signal 2007-02-08 16:08:39 +11:00
mca
md [PATCH] md: remove unnecessary printk when raid5 gets an unaligned read. 2007-01-26 13:51:00 -08:00
media USB: remove duplicate device id from zc0301 2007-02-07 15:44:40 -08:00
message [SCSI] fusion: bump version 2007-01-06 09:32:49 -06:00
mfd
misc Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2007-02-07 15:36:08 -08:00
mmc mmc: tifm: replace kmap with page_address 2007-02-04 20:54:12 +01:00
mtd [PATCH] mtd/nand/cafe.c missing include of dma-mapping.h 2007-01-30 08:39:20 -08:00
net [TG3]: Avoid an expensive divide. 2007-02-08 12:38:57 -08:00
nubus
oprofile
parisc [PATCH] getting rid of all casts of k[cmz]alloc() calls 2006-12-13 09:05:58 -08:00
parport [PATCH] Kconfig refactoring for better menu nesting 2006-12-10 09:55:39 -08:00
pci Merge master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6 2007-02-07 19:32:36 -08:00
pcmcia Driver core: convert pcmcia code to use struct device 2007-02-07 10:37:11 -08:00
pnp PNPACPI: remove EXPERIMENTAL dependency 2007-01-26 02:15:57 -05:00
ps3 [POWERPC] PS3: Move vuart declarations to ps3.h 2007-02-07 14:03:20 +11:00
rapidio
rtc [PATCH] remove __devinit markings from rtc_sysfs_add_device() 2007-01-26 13:51:00 -08:00
s390 [S390] Avoid excessive inlining. 2007-02-05 21:18:53 +01:00
sbus [PATCH] getting rid of all casts of k[cmz]alloc() calls 2006-12-13 09:05:58 -08:00
scsi PCI: remove duplicate device id from ipr 2007-02-07 15:50:06 -08:00
serial Merge branch 'linux-2.6' 2007-02-07 14:05:13 +11:00
sh
sn
spi Revert "Driver core: convert SPI code to use struct device" 2007-02-07 21:34:08 -08:00
tc
telephony
usb Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6 2007-02-07 19:23:21 -08:00
video Pull output-switch into test branch 2007-02-03 01:39:22 -05:00
w1 [PATCH] w1: Fix for kconfig entry typo 2006-12-13 09:05:48 -08:00
zorro
Kconfig [PATCH] kvm: userspace interface 2006-12-10 09:57:22 -08:00
Makefile [PATCH] kvm: userspace interface 2006-12-10 09:57:22 -08:00