Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753180Ab0KUAD7 (ORCPT ); Sat, 20 Nov 2010 19:03:59 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:50828 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750895Ab0KUAD6 convert rfc822-to-8bit (ORCPT ); Sat, 20 Nov 2010 19:03:58 -0500 MIME-Version: 1.0 In-Reply-To: References: From: Linus Torvalds Date: Sat, 20 Nov 2010 16:03:35 -0800 Message-ID: Subject: Re: [PATCH][resend][SCSI] Reduce number of sequential pointer derefs in scsi_error.c and reduce size as well To: Jesper Juhl Cc: linux-scsi@vger.kernel.org, "James E.J. Bottomley" , linux-kernel@vger.kernel.org, Eric Youngdale , "David S. Miller" , Mike Anderson , Russell King , Andrew Morton Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1371 Lines: 39 On Sat, Nov 20, 2010 at 12:30 PM, Jesper Juhl wrote: > > Ok, I tried doing that (see patch below) Actually, you kind of chose exactly the reverse of the functions I'd have chosen. Try doing the added parameter to the small static helper functions. Those are the ones that tend to get inlined, and then the parameter should actually result in _fewer_ pointer reloads. So the ones like this: > ?static int __scsi_try_to_abort_cmd(struct scsi_cmnd *scmd) > ?{ > - ? ? ? if (!scmd->device->host->hostt->eh_abort_handler) > + ? ? ? struct scsi_host_template *hostt = scmd->device->host->hostt; > + ? ? ? if (!hostt->eh_abort_handler) > ? ? ? ? ? ? ? ?return FAILED; > - > - ? ? ? return scmd->device->host->hostt->eh_abort_handler(scmd); > + ? ? ? return hostt->eh_abort_handler(scmd); > ?} Where the function is trivial, and almost all it does is to just dereference those pointers. If that function got the "host" pointer as an argument, it should make it much smaller. Because half of that function is that "scmd->device->host" lookup. (ok, that's exaggerated, but not by much). Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/