public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch
@ 2010-01-21 13:40 Håkon Bugge
       [not found] ` <ED0695A5-CBE3-4CE2-A20C-BBC7BEF28C33-U0mLk4xYmo8@public.gmane.org>
       [not found] ` <4B5BD8B5.2080102@voltaire.com>
  0 siblings, 2 replies; 7+ messages in thread
From: Håkon Bugge @ 2010-01-21 13:40 UTC (permalink / raw)
  To: Vladimir Sokolovsky; +Cc: OFED mailing list, Or Gerlitz

ibv_asyncwatch defaults to block-buffering when stdout is redirected to a file or pipe. This fix makes it more usable in scripted environments.

Signed-off-by: Hakon Bugge <Haakon.Bugge-xsfywfwIY+M@public.gmane.org>
---
diff --git a/examples/asyncwatch.c b/examples/asyncwatch.c
index e56b4dc..f9fe6ff 100644
--- a/examples/asyncwatch.c
+++ b/examples/asyncwatch.c
@@ -98,6 +98,9 @@ int main(int argc, char *argv[])
                return 1;
        }
 
+       /* Force line-buffering if stdout is redirected */
+       setlinebuf(stdout);
+
        printf("%s: async event FD %d\n",
               ibv_get_device_name(*dev_list), context->async_fd);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch
       [not found] ` <ED0695A5-CBE3-4CE2-A20C-BBC7BEF28C33-U0mLk4xYmo8@public.gmane.org>
@ 2010-01-21 14:18   ` Bart Van Assche
       [not found]     ` <e2e108261001210618p476ed03bofa2e46c223578e1a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2010-01-21 14:18 UTC (permalink / raw)
  To: Håkon Bugge; +Cc: Vladimir Sokolovsky, OFED mailing list, Or Gerlitz

On Thu, Jan 21, 2010 at 2:40 PM, Håkon Bugge <Haakon.Bugge-xsfywfwIY+M@public.gmane.org> wrote:
> ibv_asyncwatch defaults to block-buffering when stdout is redirected to a file or pipe. This fix makes it more usable in scripted environments.
>
> Signed-off-by: Hakon Bugge <Haakon.Bugge-xsfywfwIY+M@public.gmane.org>
> ---
> diff --git a/examples/asyncwatch.c b/examples/asyncwatch.c
> index e56b4dc..f9fe6ff 100644
> --- a/examples/asyncwatch.c
> +++ b/examples/asyncwatch.c
> @@ -98,6 +98,9 @@ int main(int argc, char *argv[])
>                return 1;
>        }
>
> +       /* Force line-buffering if stdout is redirected */
> +       setlinebuf(stdout);
> +
>        printf("%s: async event FD %d\n",
>               ibv_get_device_name(*dev_list), context->async_fd);

It might be a good idea to replace setlinebuf() by setvbuf().
setlinebuf() is a BSD function while setvbuf is POSIX (see also
http://opengroup.org/onlinepubs/009695399/functions/setvbuf.html).

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch
       [not found]     ` <e2e108261001210618p476ed03bofa2e46c223578e1a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2010-01-21 15:01       ` Håkon Bugge
       [not found]         ` <C25CCF03-2542-4C8D-9AF4-122DBF56F856-UdXhSnd/wVw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Håkon Bugge @ 2010-01-21 15:01 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Vladimir Sokolovsky, OFED mailing list, Or Gerlitz

I guess it depends. ibverbs has other non-POSIX compliant libc functions - so I am not sure there is a POSIX policy enforcement.

If I understand correctly, the charter of OFED is to produce a Linux distribution (and also a Windows distro).

setlinebuf() is pretty intuitive to understand, compared to setvbuf().

-h


On Jan 21, 2010, at 15:18 , Bart Van Assche wrote:

> On Thu, Jan 21, 2010 at 2:40 PM, Håkon Bugge <Haakon.Bugge-xsfywfwIY+M@public.gmane.org> wrote:
>> ibv_asyncwatch defaults to block-buffering when stdout is redirected to a file or pipe. This fix makes it more usable in scripted environments.
>> 
>> Signed-off-by: Hakon Bugge <Haakon.Bugge-xsfywfwIY+M@public.gmane.org>
>> ---
>> diff --git a/examples/asyncwatch.c b/examples/asyncwatch.c
>> index e56b4dc..f9fe6ff 100644
>> --- a/examples/asyncwatch.c
>> +++ b/examples/asyncwatch.c
>> @@ -98,6 +98,9 @@ int main(int argc, char *argv[])
>>                return 1;
>>        }
>> 
>> +       /* Force line-buffering if stdout is redirected */
>> +       setlinebuf(stdout);
>> +
>>        printf("%s: async event FD %d\n",
>>               ibv_get_device_name(*dev_list), context->async_fd);
> 
> It might be a good idea to replace setlinebuf() by setvbuf().
> setlinebuf() is a BSD function while setvbuf is POSIX (see also
> http://opengroup.org/onlinepubs/009695399/functions/setvbuf.html).
> 
> Bart.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Håkon Bugge
Haakon.bugge-U0mLk4xYmo8@public.gmane.org
+47 924 84 514



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch
       [not found]     ` <23AC7B6E-377F-4CFC-AD9D-0D2FD27662C7-UdXhSnd/wVw@public.gmane.org>
@ 2010-01-25  9:44       ` Or Gerlitz
       [not found]         ` <4B5D67FE.80509-hKgKHo2Ms0FWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Or Gerlitz @ 2010-01-25  9:44 UTC (permalink / raw)
  To: Håkon Bugge, Vladimir Sokolovsky; +Cc: linux-rdma, Roland Dreier

Håkon Bugge wrote:
> I used the information at www.openfabrics.org/git/?p=ofed_1_2_5/libibverbs.git;a=summary 
> which states the "owner" to be Vlad. May be that confused me. I'll send a copy to Roland

Roland's user space git trees are all hosted @ kernel.org 
the libibverbs one is git://git.kernel.org/pub/scm/libs/infiniband/libibverbs.git
you can find there the libmlx4 and libmthca ones as well.

Vlad - is there a way to prevent such confusion in the future, maybe put a clear comment
in the header of the ofa git page?

Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch
       [not found]         ` <4B5D67FE.80509-hKgKHo2Ms0FWk0Htik3J/w@public.gmane.org>
@ 2010-01-25  9:47           ` Vladimir Sokolovsky
  0 siblings, 0 replies; 7+ messages in thread
From: Vladimir Sokolovsky @ 2010-01-25  9:47 UTC (permalink / raw)
  To: Or Gerlitz; +Cc: Håkon Bugge, linux-rdma, Roland Dreier

Or Gerlitz wrote:
> Håkon Bugge wrote:
>> I used the information at www.openfabrics.org/git/?p=ofed_1_2_5/libibverbs.git;a=summary 
>> which states the "owner" to be Vlad. May be that confused me. I'll send a copy to Roland
> 
> Roland's user space git trees are all hosted @ kernel.org 
> the libibverbs one is git://git.kernel.org/pub/scm/libs/infiniband/libibverbs.git
> you can find there the libmlx4 and libmthca ones as well.
> 
> Vlad - is there a way to prevent such confusion in the future, maybe put a clear comment
> in the header of the ofa git page?
> 
> Or.
> --

I'll update comments for the OFED's git trees.

Regards,
Vladimir
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch
       [not found]         ` <C25CCF03-2542-4C8D-9AF4-122DBF56F856-UdXhSnd/wVw@public.gmane.org>
@ 2010-06-02 17:05           ` Roland Dreier
       [not found]             ` <ada7hmhtle3.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Roland Dreier @ 2010-06-02 17:05 UTC (permalink / raw)
  To: Håkon Bugge
  Cc: Bart Van Assche, Vladimir Sokolovsky, OFED mailing list,
	Or Gerlitz

 > setlinebuf() is pretty intuitive to understand, compared to setvbuf().

I finally applied this; however in the end I decided to do

	setvbuf(stdout, NULL, _IOLBF, 0);

instead of setlinebuf(), since in the past I've prefered more pedantic
stuff (eg posix_memalign instead of memalign) to the older simpler
traditional functions.  Kind of a trivial issue either way anyway.
-- 
Roland Dreier <rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org> || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch
       [not found]             ` <ada7hmhtle3.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
@ 2010-06-03 10:54               ` Håkon Bugge
  0 siblings, 0 replies; 7+ messages in thread
From: Håkon Bugge @ 2010-06-03 10:54 UTC (permalink / raw)
  To: Roland Dreier
  Cc: Bart Van Assche, Vladimir Sokolovsky, OFED mailing list,
	Or Gerlitz


On Jun 2, 2010, at 19:05 , Roland Dreier wrote:

>> setlinebuf() is pretty intuitive to understand, compared to setvbuf().
> 
> I finally applied this; however in the end I decided to do
> 
> 	setvbuf(stdout, NULL, _IOLBF, 0);
> 
> instead of setlinebuf(), since in the past I've prefered more pedantic
> stuff (eg posix_memalign instead of memalign) to the older simpler
> traditional functions.  Kind of a trivial issue either way anyway.


Agree. Thanks anyway.


Håkon

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-06-03 10:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-21 13:40 [PATCH] libibverbs: Force line-buffering in ibv_asyncwatch Håkon Bugge
     [not found] ` <ED0695A5-CBE3-4CE2-A20C-BBC7BEF28C33-U0mLk4xYmo8@public.gmane.org>
2010-01-21 14:18   ` Bart Van Assche
     [not found]     ` <e2e108261001210618p476ed03bofa2e46c223578e1a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-01-21 15:01       ` Håkon Bugge
     [not found]         ` <C25CCF03-2542-4C8D-9AF4-122DBF56F856-UdXhSnd/wVw@public.gmane.org>
2010-06-02 17:05           ` Roland Dreier
     [not found]             ` <ada7hmhtle3.fsf-BjVyx320WGW9gfZ95n9DRSW4+XlvGpQz@public.gmane.org>
2010-06-03 10:54               ` Håkon Bugge
     [not found] ` <4B5BD8B5.2080102@voltaire.com>
     [not found]   ` <23AC7B6E-377F-4CFC-AD9D-0D2FD27662C7@Sun.COM>
     [not found]     ` <23AC7B6E-377F-4CFC-AD9D-0D2FD27662C7-UdXhSnd/wVw@public.gmane.org>
2010-01-25  9:44       ` Or Gerlitz
     [not found]         ` <4B5D67FE.80509-hKgKHo2Ms0FWk0Htik3J/w@public.gmane.org>
2010-01-25  9:47           ` Vladimir Sokolovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox