怎么修改pipe_buf大小

太乙 2010-06-02 12:11:27
如何修改pipe_buf的大小呢?

1、修改limits.h里的#define PIPE_BUF 4096
重新编译内核?我看网上有人这么做了,但是没成功

2、直接修改/etc/security/limits.conf
???怎么修改?能行么?

3、其他??


有人能提供一个简单的方法么?最好不用重新编译内核的!
...全文
658 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
太乙 2010-06-03
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 hzcpig 的回复:]
严重怀疑是多进程同时读写造成的错乱问题。以前做日志系统的时候也是参考syslog,多进程的写日志动作只是发事件,由唯一的进程接收事件然后写入日志文件。

希望楼主解决后回头说说原因,关注。
[/Quote]呵呵,你的怀疑是对的!多进程同时写,而一条日志超长(大于了pipe_buf),所以不能保证原子性!就有可能错乱。。。
justin_luhui 2010-06-03
  • 打赏
  • 举报
回复
xuexi了
handledos 2010-06-02
  • 打赏
  • 举报
回复
ls说的很详细了
steptodream 2010-06-02
  • 打赏
  • 举报
回复
What good would it do you to rebuild your kernel with 'PIPE_BUF' set to
some value other than the number of bytes that one can write to a pipe
atomically?

Perhaps you are under the mistaken impression that 'PIPE_BUF'
determines how many bytes you can write to a pipe atomically (that is,
that the kernel accesses this value and uses it to influence how pipes
behave). It does not, it only *tells* you how many bytes you can write
to a pipe atomically. If you change it to something else, it will no
longer do so, making it useless.

PIPE_BUF is a consequence of other logic in the kernel, it is not a
configuration parameter.

http://software.itags.org/linux-unix/332459/
hzcpig 2010-06-02
  • 打赏
  • 举报
回复
严重怀疑是多进程同时读写造成的错乱问题。以前做日志系统的时候也是参考syslog,多进程的写日志动作只是发事件,由唯一的进程接收事件然后写入日志文件。

希望楼主解决后回头说说原因,关注。
太乙 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 steptodream 的回复:]
没遇到过 还真不知道如何解决
一条日志怎么那么大啊
我是觉得一条日志超过4k 这样详细的日志信息似乎没必要啊
[/Quote]呵呵,谢谢你的帮忙,我再找找~~~
steptodream 2010-06-02
  • 打赏
  • 举报
回复
没遇到过 还真不知道如何解决
一条日志怎么那么大啊
我是觉得一条日志超过4k 这样详细的日志信息似乎没必要啊
太乙 2010-06-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 steptodream 的回复:]
What good would it do you to rebuild your kernel with 'PIPE_BUF' set to
some value other than the number of bytes that one can write to a pipe
atomically?

Perhaps you are under the mistaken impre……
[/Quote]

谢谢,现在我遇到一个问题,就是apache写日志的问题,具体可以参见:
http://topic.csdn.net/u/20100601/11/e9b8bc91-dae8-4672-8b20-cff4c71dee0f.html
http://topic.csdn.net/u/20100601/11/b6f12ee7-daf7-4518-a700-f268c74ce712.html
http://topic.csdn.net/u/20100601/11/0b4a79e2-3444-461c-a800-0802cd58d038.html

我测试了一下,如果apache的单条日志超过4k,就会有日志乱掉的情况!

而使用ulimit -p, 发现8*512=4096

而如果单条日志不超过4k,就没有日志乱掉的情况!

网上查了下,好像是apache在写入的时候,是用管道,而管道的原子操作,是由pipe_buf来决定大小的!

所有有此一问!

如果不修改这个值,那么我写日志的时候是不是必须加锁呢??apache本身有这个机制??

谢谢~~~

4,465

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧