From owner-freebsd-scsi@FreeBSD.ORG Mon Nov 20 22:18:51 2006 Return-Path: X-Original-To: freebsd-scsi@freebsd.org Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8394716A407 for ; Mon, 20 Nov 2006 22:18:51 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.229]) by mx1.FreeBSD.org (Postfix) with ESMTP id 707CD43D73 for ; Mon, 20 Nov 2006 22:18:32 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: by wx-out-0506.google.com with SMTP id s18so1699050wxc for ; Mon, 20 Nov 2006 14:18:50 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=PJCnG0mAGgRT6wrXLFmB4zoqTJIKJRtyescqpnba4m/R08tAjrLOZMSSsjc749N2AwcIcpXczFKU1hVMm/iu3qUzAVHHhQx40cISclNkV+a2afT5kzmfLfRscsuelE0uje2i8NLSzCVZpanPRC/OqK1Gr/tulxSWGKkOTEC9wpE= Received: by 10.70.117.1 with SMTP id p1mr1444861wxc.1164061123769; Mon, 20 Nov 2006 14:18:43 -0800 (PST) Received: by 10.70.12.2 with HTTP; Mon, 20 Nov 2006 14:18:43 -0800 (PST) Message-ID: <3bbf2fe10611201418m15d50703m37d9d5620e5c832d@mail.gmail.com> Date: Mon, 20 Nov 2006 23:18:43 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Brooks Davis" In-Reply-To: <20061120221153.GA5155@lor.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20061119161631.L44297@ns1.feral.com> <3bbf2fe10611191631h6883b862uf8088533913a7bc6@mail.gmail.com> <20061120221153.GA5155@lor.one-eyed-alien.net> X-Google-Sender-Auth: 003ec0948c0bb350 Cc: freebsd-scsi@freebsd.org, mjacob@freebsd.org Subject: Re: a code reduction function addition to cam_xpt X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Nov 2006 22:18:51 -0000 2006/11/20, Brooks Davis : > On Mon, Nov 20, 2006 at 01:31:01AM +0100, Attilio Rao wrote: > > 2006/11/20, mjacob@freebsd.org : > > >There are *far* too many: > > > > > > xpt_print_path(path); > > > printf("foo\n"); > > > > > >constructs. How about we just join them? > > > > > >==== //depot/projects/newisp/cam/cam_xpt.c#12 - > > >/home/FreeBSD/p4/newisp/cam/cam_xpt.c ==== > > >@@ -63,6 +63,7 @@ > > > #include > > > #include > > > #include > > >+#include /* for xpt_print below */ > > > #include "opt_cam.h" > > > > > > /* Datastructures internal to the xpt layer */ > > >@@ -4160,6 +4161,16 @@ > > > } > > > } > > > > > >+void > > >+xpt_print(struct cam_path *path, const char *fmt, ...) > > >+{ > > >+ va_list ap; > > >+ xpt_print_path(path); > > >+ va_start(ap, fmt); > > >+ vprintf(fmt, ap); > > >+ va_end(ap); > > >+} > > >+ > > >==== //depot/projects/newisp/cam/cam_xpt.h#1 - > > >/home/FreeBSD/p4/newisp/cam/cam_xpt.h ==== > > >@@ -62,6 +62,7 @@ > > > int xpt_path_comp(struct cam_path *path1, > > > struct cam_path *path2); > > > void xpt_print_path(struct cam_path *path); > > >+void xpt_print(struct cam_path *path, const char *fmt, > > >...); > > > int xpt_path_string(struct cam_path *path, char *str, > > > size_t str_len); > > > path_id_t xpt_path_path_id(struct cam_path *path); > > > > Would not be better a preprocessing stub? > > > > something like: > > > > #define XPT_PRINT(path, fmt, ...) do { > > \ > > xpt_print_path(path); > > \ > > printf(fmt, __VA_ARGS__); > > \ > > } while (0) > > Why? What is gained? FWIW, when I added if_printif it reduced kernel > size by several KB. If there's a similar effect here we should take > advantage of it. It is simply faster (one function calling less), even if probabilly this could be mitigated with -fomit-frame-pointer (IMHO, this is not as over used as if_printf...). Attilio -- Peace can only be achieved by understanding - A. Einstein