OSDN Git Service

76501fa308e73766ff88a3014fda8db3407d2d4e
[linuxjm/LDP_man-pages.git] / draft / man2 / ioprio_set.2
1 .\" This is _*_ nroff _*_ source. Emacs, gimme all those colors :)
2 .\"
3 .\" Copyright (c) International Business Machines orp., 2006
4 .\"
5 .\" This program is free software; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" This program is distributed in the hope that it will be useful,
11 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
12 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 .\" the GNU General Public License for more details.
14 .\"
15 .\" You should have received a copy of the GNU General Public License
16 .\" along with this program; if not, write to the Free Software
17 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 .\" MA 02111-1307 USA
19 .\"
20 .\" HISTORY:
21 .\" 2006-04-27, created by Eduardo M. Fleury <efleury@br.ibm.com>
22 .\" with various additions by Michael Kerrisk <mtk.manpages@gmail.com>
23 .\"
24 .\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI
25 .\"         all rights reserved.
26 .\" Translated 2007-01-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.43
27 .\" Updated 2008-08-06, Akihiro MOTOKI, LDP v3.05
28 .\"
29 .TH IOPRIO_SET 2 2008-07-09 "Linux" "Linux Programmer's Manual"
30 .\"O .SH NAME
31 .SH 名前
32 .\"O ioprio_get, ioprio_set \- get/set I/O scheduling class and priority
33 ioprio_get, ioprio_set \- I/O スケジューリングクラスと優先度の設定/取得
34 .\"O .SH SYNOPSIS
35 .SH 書式
36 .nf
37 .BI "int ioprio_get(int " which ", int " who );
38 .BI "int ioprio_set(int " which ", int " who ", int " ioprio );
39 .fi
40 .\"O .SH DESCRIPTION
41 .SH 説明
42 .\"O The
43 .\"O .BR ioprio_get ()
44 .\"O and
45 .\"O .BR ioprio_set ()
46 .\"O system calls respectively get and set the I/O scheduling class and
47 .\"O priority of one or more processes.
48 システムコール
49 .BR ioprio_get ()
50 /
51 .BR ioprio_set ()
52 は、(1つ以上の) プロセスの I/O スケジューリングクラスと
53 優先度の取得/設定を行う。
54
55 .\"O The
56 .\"O .I which
57 .\"O and
58 .\"O .I who
59 .\"O arguments identify the process(es) on which the system
60 .\"O calls operate.
61 .\"O The
62 .\"O .I which
63 .\"O argument determines how
64 .\"O .I who
65 .\"O is interpreted, and has one of the following values:
66 .I which
67
68 .I who
69 引き数でシステムコールの操作対象となるプロセスを指示する。
70 .I which
71 引き数は、
72 .I who
73 をどのように解釈するかを決めるもので、以下のいずれか一つを指定する。
74 .TP
75 .B IOPRIO_WHO_PROCESS
76 .\"O .I who
77 .\"O is a process ID identifying a single process.
78 .I who
79 はプロセスID であり、指定された 1 プロセスが対象となる。
80 .TP
81 .B IOPRIO_WHO_PGRP
82 .\"O .I who
83 .\"O is a process group ID identifying all the members of a process group.
84 .I who
85 はプロセスグループID であり、プロセスグループの全メンバが対象となる。
86 .TP
87 .B IOPRIO_WHO_USER
88 .\"O .I who
89 .\"O is a user ID identifying all of the processes that
90 .\"O have a matching real UID.
91 .I who
92 はユーザID であり、実 UID に一致する全プロセスが対象となる。
93 .PP
94 .\"O If
95 .\"O .I which
96 .\"O is specified as
97 .\"O .B IOPRIO_WHO_PGRP
98 .\"O or
99 .\"O .B IOPRIO_WHO_USER
100 .\"O when calling
101 .\"O .BR ioprio_get (),
102 .\"O and more than one process matches
103 .\"O .IR who ,
104 .\"O then the returned priority will be the highest one found among
105 .\"O all of the matching processes.
106 .\"O One priority is said to be
107 .\"O higher than another one if it belongs to a higher priority
108 .\"O class
109 .\"O .RB ( IOPRIO_CLASS_RT
110 .\"O is the highest priority class;
111 .\"O .B IOPRIO_CLASS_IDLE
112 .\"O is the lowest)
113 .\"O or if it belongs to the same priority class as the other process but
114 .\"O has a higher priority level (a lower priority number means a
115 .\"O higher priority level).
116 .BR ioprio_get ()
117 の呼び出し時に
118 .I which
119
120 .B IOPRIO_WHO_PGRP
121
122 .B IOPRIO_WHO_USER
123 が指定され、
124 .I who
125 に一致するプロセスが複数あった場合、
126 一致するプロセス全体の中で最も高い優先度が返される。
127 優先度が高いとは、より高い優先度クラスに属している
128 .RB ( IOPRIO_CLASS_RT
129 が最も高い優先度クラスで、
130 .B IOPRIO_CLASS_IDLE
131 が最も低い)、もしくは
132 同じ優先度クラスに属しているが優先度レベルが高い
133 (優先度番号が小さい方が優先度レベルが高いことを意味する)、
134 ということである。
135
136 .\"O The
137 .\"O .I ioprio
138 .\"O argument given to
139 .\"O .BR ioprio_set ()
140 .\"O is a bit mask that specifies both the scheduling class and the
141 .\"O priority to be assigned to the target process(es).
142 .\"O The following macros are used for assembling and dissecting
143 .\"O .I ioprio
144 .\"O values:
145 .BR ioprio_set ()
146 に渡す
147 .I ioprio
148 引き数は、対象となるプロセスに割り当てるスケジューリングクラスと
149 優先度の両方を指定するビットマスクである。
150 .I ioprio
151 の値を組み立てたり解釈するのに、以下のマクロが利用できる。
152 .TP
153 .BI IOPRIO_PRIO_VALUE( class ", " data )
154 .\"O Given a scheduling
155 .\"O .I class
156 .\"O and priority
157 .\"O .RI ( data ),
158 .\"O this macro combines the two values to produce an
159 .\"O .I ioprio
160 .\"O value, which is returned as the result of the macro.
161 スケジューリングクラス
162 .I class
163 と優先度
164 .RI ( data )
165 を与えると、このマクロは 2つの値を組み合わせて、
166 .I ioprio
167 値を生成し、マクロの結果として返す。
168 .TP
169 .BI IOPRIO_PRIO_CLASS( mask )
170 .\"O Given
171 .\"O .I mask
172 .\"O (an
173 .\"O .I ioprio
174 .\"O value), this macro returns its I/O class component, that is,
175 .\"O one of the values
176 .\"O .BR IOPRIO_CLASS_RT ,
177 .\"O .BR IOPRIO_CLASS_BE ,
178 .\"O or
179 .\"O .BR IOPRIO_CLASS_IDLE .
180 .I mask
181 .RI ( ioprio
182 値) を与えると、このマクロは I/O クラス要素、つまり
183 .BR IOPRIO_CLASS_RT ,
184 .BR IOPRIO_CLASS_BE ,
185 .B IOPRIO_CLASS_IDLE
186 のいずれか一つの値を返す。
187 .TP
188 .BI IOPRIO_PRIO_DATA( mask )
189 .\"O Given
190 .\"O .I mask
191 .\"O (an
192 .\"O .I ioprio
193 .\"O value), this macro returns its priority
194 .\"O .RI ( data )
195 .\"O component.
196 .I mask
197 .RI ( ioprio
198 値) を与えると、このマクロは優先度
199 .RI ( data )
200 要素を返す。
201 .PP
202 .\"O See the NOTES section for more
203 .\"O information on scheduling classes and priorities.
204 スケジューリングクラスと優先度に関する詳しい情報は、
205 「備考」の節を参照のこと。
206
207 .\"O I/O priorities are supported for reads and for synchronous
208 .\"O .RB ( O_DIRECT ,
209 .\"O .BR O_SYNC )
210 .\"O writes.
211 .\"O I/O priorities are not supported for asynchronous
212 .\"O writes because they are issued outside the context of the program
213 .\"O dirtying the memory, and thus program-specific priorities do not apply.
214 I/O 優先度は読み出しと同期書き込み
215 .RB ( O_DIRECT ,
216 .BR O_SYNC )
217 に対応している。
218 I/O 優先度は非同期書き込みには対応していない。なぜなら、
219 非同期書き込みはメモリ書き換えを行うプログラムの動作 (context) とは
220 関係なく発行され、そのためプログラム単位の優先度は適用されないから
221 である。
222 .\"O .SH "RETURN VALUE"
223 .SH 返り値
224 .\"O On success,
225 .\"O .BR ioprio_get ()
226 .\"O returns the
227 .\"O .I ioprio
228 .\"O value of the process with highest I/O priority of any of the processes
229 .\"O that match the criteria specified in
230 .\"O .I which
231 .\"O and
232 .\"O .IR who .
233 .\"O On error, \-1 is returned, and
234 .\"O .I errno
235 .\"O is set to indicate the error.
236 成功すると、
237 .BR ioprio_get ()
238 は、
239 .I which
240
241 .I who
242 で指定された基準に合致した全プロセスで最も高い I/O 優先度を持つプロセスの
243 .I ioprio
244 値を返す。
245 エラーの場合、\-1 を返し、
246 .I errno
247 にエラーを示す値を設定する。
248 .PP
249 .\"O On success,
250 .\"O .BR ioprio_set ()
251 .\"O returns 0.
252 .\"O On error, \-1 is returned, and
253 .\"O .I errno
254 .\"O is set to indicate the error.
255 成功すると、
256 .BR ioprio_set ()
257 は 0 を返す。
258 エラーの場合、\-1 を返し、
259 .I errno
260 にエラーを示す値を設定する。
261 .\"O .SH ERRORS
262 .SH エラー
263 .TP
264 .B EINVAL
265 .\"O Invalid value for
266 .\"O .I which
267 .\"O or
268 .\"O .IR ioprio .
269 .\"O Refer to the NOTES section for available scheduler
270 .\"O classes and priority levels for
271 .\"O .IR ioprio .
272 .I which
273
274 .I ioprio
275 の値が不正である。
276 .I ioprio
277 用に指定可能なスケジューラクラスと優先度レベルについては
278 「備考」を参照のこと。
279 .TP
280 .B EPERM
281 .\"O The calling process does not have the privilege needed to assign this
282 .\"O .I ioprio
283 .\"O to the specified process(es).
284 .\"O See the NOTES section for more information on required
285 .\"O privileges for
286 .\"O .BR ioprio_set ().
287 呼び出し元プロセスが、指定されたプロセスに
288 .I ioprio
289 を割り当てるのに必要な権限を持っていない。
290 .BR ioprio_set ()
291 に必要な権限についての詳しい情報は「備考」の節を参照のこと。
292 .TP
293 .B ESRCH
294 .\"O No process(es) could be found that matched the specification in
295 .\"O .I which
296 .\"O and
297 .\"O .IR who .
298 .I which
299
300 .I who
301 で指定された基準に合致するプロセスが見つからなかった。
302 .\"O .SH VERSIONS
303 .SH バージョン
304 .\"O These system calls have been available on Linux since
305 .\"O kernel 2.6.13.
306 これらのシステムコールはカーネル 2.6.13 以降の Linux で利用可能である。
307 .\"O .SH "CONFORMING TO"
308 .SH 準拠
309 .\"O These system calls are Linux-specific.
310 これらのシステムコールは Linux 独自である。
311 .\"O .SH NOTES
312 .SH 備考
313 .\"O Glibc does not provide wrapper for these system calls; call them using
314 .\"O .BR syscall (2).
315 glibc はこれらのシステムコールに対するラッパー関数を提供していない。
316 .BR syscall (2)
317 を使って呼び出すこと。
318
319 .\"O These system calls only have an effect when used
320 .\"O in conjunction with an I/O scheduler that supports I/O priorities.
321 .\"O As at kernel 2.6.17 the only such scheduler is the Completely Fair Queuing
322 .\"O (CFQ) I/O scheduler.
323 これらのシステムコールは、I/O 優先度に対応した I/O スケジューラと
324 組み合わせて使用された場合にのみ効果を持つ。
325 カーネル 2.6.17 では、この条件を満たすスケジューラは
326 Completely Fair Queuing (CFQ) I/O スケジューラだけである。
327 .\"O .SS "Selecting an I/O Scheduler"
328 .SS I/O スケジューラの選択
329 .\"O I/O Schedulers are selected on a per-device basis via the special
330 .\"O file
331 .\"O .IR /sys/block/<device>/queue/scheduler .
332 I/O スケジューラの選択はデバイス単位に行われ、その選択は
333 スペシャルファイル
334 .I /sys/block/<device>/queue/scheduler
335 経由で行われる。
336
337 .\"O One can view the current I/O scheduler via the
338 .\"O .I /sys
339 .\"O file system.
340 .\"O For example, the following command
341 .\"O displays a list of all schedulers currently loaded in the kernel:
342 現在の I/O スケジューラは
343 .I /sys
344 ファイルシステム経由で参照できる。例えば、以下のコマンドを実行すると、
345 現在カーネルでロードされているスケジューラの全リストが表示される。
346 .sp
347 .RS
348 .nf
349 .RB "$" " cat /sys/block/hda/queue/scheduler"
350 noop anticipatory deadline [cfq]
351 .fi
352 .RE
353 .sp
354 .\"O The scheduler surrounded by brackets is the one actually
355 .\"O in use for the device
356 .\"O .RI ( hda
357 .\"O in the example).
358 括弧で囲まれたスケジューラがそのデバイス (上の例では
359 .IR hda )
360 について実際に使用されているスケジューラである。
361 .\"O Setting another scheduler is done by writing the name of the
362 .\"O new scheduler to this file.
363 .\"O For example, the following command will set the
364 .\"O scheduler for the
365 .\"O .I hda
366 .\"O device to
367 .\"O .IR cfq :
368 別のスケジューラを設定するには、このファイルに新しいスケジューラ名を
369 書き込めばよい。例えば、以下のコマンドを実行すると、デバイス
370 .I hda
371 のスケジューラとして
372 .I cfq
373 が設定される。
374 .sp
375 .RS
376 .nf
377 .RB "$" " su"
378 Password:
379 .RB "#" " echo cfq > /sys/block/hda/queue/scheduler"
380 .fi
381 .RE
382 .\"O .SS "The Completely Fair Queuing (CFQ) I/O Scheduler"
383 .SS "Completely Fair Queuing (CFQ) I/O スケジューラ"
384 .\"O Since v3 (aka CFQ Time Sliced) CFQ implements
385 .\"O I/O nice levels similar to those
386 .\"O of CPU scheduling.
387 .\"O These nice levels are grouped in three scheduling classes
388 .\"O each one containing one or more priority levels:
389 バージョン 3 (別名 CFQ Time Sliced) 以降、
390 CPU スケジューリングと同様の I/O nice レベルが CFQ に実装されている。
391 これらの nice レベルは 3つのスケジューリングクラスに分類でき、
392 各スケジューリングクラスにつき 1つ以上の優先度レベルが定義されている。
393 .TP
394 .BR IOPRIO_CLASS_RT " (1)"
395 .\"O This is the real-time I/O class.
396 .\"O This scheduling class is given
397 .\"O higher priority than any other class:
398 .\"O processes from this class are
399 .\"O given first access to the disk every time.
400 .\"O Thus this I/O class needs to be used with some
401 .\"O care: one I/O real-time process can starve the entire system.
402 .\"O Within the real-time class,
403 .\"O there are 8 levels of class data (priority) that determine exactly
404 .\"O how much time this process needs the disk for on each service.
405 .\"O The highest real-time priority level is 0; the lowest is 7.
406 .\"O In the future this might change to be more directly mappable to
407 .\"O performance, by passing in a desired data rate instead.
408 これはリアルタイム I/O クラスである。
409 このスケジューリングクラスには他のクラスよりも高い優先度が与えられる。
410 このクラスのプロセスには、常にディスクへのアクセスが優先して
411 割り当てられる。そのため、この I/O クラスを使う際には、
412 たった一つの リアルタイム I/O クラスのプロセスにより
413 システム全体のディスクアクセスができなくなってしまうことがある
414 という点に、注意を払う必要がある。
415 このクラスには、8 段階の class data (優先度レベル) がある。
416 この値は、そのプロセスが 1回のディスクアクセスにどれだけの
417 時間が必要かを正確に決めるためのものである。
418 最高のリアルタイム優先度レベルは 0 で、最低は 7 である。
419 将来的には、優先度レベルは、希望するデータレートを渡すなど、
420 より直接的に性能条件を反映できるように変更されるかもしれない。
421 .TP
422 .BR IOPRIO_CLASS_BE " (2)"
423 .\"O This is the best-effort scheduling class,
424 .\"O which is the default for any process
425 .\"O that hasn't set a specific I/O priority.
426 .\"O The class data (priority) determines how much
427 .\"O I/O bandwidth the process will get.
428 .\"O Best-effort priority levels are analogous to CPU nice values
429 .\"O (see
430 .\"O .BR getpriority (2)).
431 .\"O The priority level determines a priority relative
432 .\"O to other processes in the best-effort scheduling class.
433 .\"O Priority levels range from 0 (highest) to 7 (lowest).
434 これは ベストエフォート・スケジューリングクラスである。
435 このクラスは、特定の I/O 優先度を設定していないプロセスの
436 デフォルト値である。
437 class data (優先度レベル) により、そのプロセスがどの程度の
438 I/O 帯域を得られるかが決定される。
439 ベストエフォート・優先度レベルは、CPU の nice 値
440 .RB ( getpriority (2)
441 参照) と同様のものである。
442 優先度レベルは、ベストエフォート・スケジューリングクラスの中で
443 他のプロセスとの相対的な優先度を決定する。
444 優先度レベルの値の範囲は 0 (最高) から 7 (最低) である。
445 .TP
446 .BR IOPRIO_CLASS_IDLE " (3)"
447 .\"O This is the idle scheduling class.
448 .\"O Processes running at this level only get I/O
449 .\"O time when no-one else needs the disk.
450 .\"O The idle class has no class data.
451 .\"O Attention is required when assigning this priority class to a process,
452 .\"O since it may become starved if higher priority processes are
453 .\"O constantly accessing the disk.
454 これは idle スケジューリングクラスである。
455 このレベルで動作するプロセスは他にディスクアクセスをしようとする
456 プロセスがない場合にのみ I/O 時間を取得する。
457 idle クラスには class data (優先度) は用意されていない。
458 プロセスにこの優先度を割り当てる際には注意が必要である。
459 なぜなら、優先度の高いプロセスが常にディスクにアクセスしている場合には
460 ディスクにアクセスできなくなる可能性があるからだ。
461 .PP
462 .\"O Refer to
463 .\"O .I Documentation/block/ioprio.txt
464 .\"O for more information on the CFQ I/O Scheduler and an example program.
465 CFQ I/O スケジューラの更なる情報とサンプルプログラムについては
466 .I Documentation/block/ioprio.txt
467 を参照のこと。
468 .\"O .SS "Required permissions to set I/O priorities"
469 .SS "I/O 優先度の設定に必要な許可"
470 .\"O Permission to change a process's priority is granted or denied based
471 .\"O on two assertions:
472 プロセスの優先度を変更する許可が得られるかどうかは
473 以下の 2つの条件に基いて決定される。
474 .TP
475 .\"O .B "Process ownership"
476 .B "プロセスの所有権"
477 .\"O An unprivileged process may only set the I/O priority of a process
478 .\"O whose real UID
479 .\"O matches the real or effective UID of the calling process.
480 .\"O A process which has the
481 .\"O .B CAP_SYS_NICE
482 .\"O capability can change the priority of any process.
483 非特権プロセスは、プロセスの実 UID が呼び出し元プロセスの実 UID もしくは
484 実効 UID と一致するプロセスの I/O 優先度のみを設定できる。
485 .B CAP_SYS_NICE
486 ケーパビリティを持つプロセスは、どのプロセスの優先度でも変更できる。
487 .TP
488 .\"O .B "What is the desired priority"
489 .B "どの優先度に設定しようとしているか"
490 .\"O Attempts to set very high priorities
491 .\"O .RB ( IOPRIO_CLASS_RT )
492 .\"O require the
493 .\"O .B CAP_SYS_ADMIN
494 .\"O capability.
495 非常に高い優先度
496 .RB ( IOPRIO_CLASS_RT )
497 を設定しようとする場合、
498 .B CAP_SYS_ADMIN
499 ケーパビリティが必要である。
500 .\"O Kernel versions up to 2.6.24 also required
501 .\"O .B CAP_SYS_ADMIN
502 .\"O to set a very low priority
503 .\"O .RB ( IOPRIO_CLASS_IDLE ),
504 .\"O but since Linux 2.6.25, this is no longer required.
505 カーネル 2.6.24 以前では、非常に低い優先度
506 .RB ( IOPRIO_CLASS_IDLE )
507 を設定するためにも
508 .B CAP_SYS_ADMIN
509 ケーパビリティが必要であったが、
510 Linux 2.6.25 以降ではもはや必要なくなった。
511 .PP
512 .\"O A call to
513 .\"O .BR ioprio_set ()
514 .\"O must follow both rules, or the call will fail with the error
515 .\"O .BR EPERM .
516 .BR ioprio_set ()
517 はこの両方のルールに従い、条件を満たさない場合、エラー
518 .B EPERM
519 で失敗する。
520 .\"O .SH BUGS
521 .SH バグ
522 .\" 6 May 07: Bug report raised:
523 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=4464
524 .\" Ulrich Drepper replied that he wasn't going to add these
525 .\" to glibc.
526 .\"O Glibc does not yet provide a suitable header file defining
527 .\"O the function prototypes and macros described on this page.
528 .\"O Suitable definitions can be found in
529 .\"O .IR linux/ioprio.h .
530 glibc は、このページに記載された関数プロトタイプやマクロを定義する
531 適切なヘッダファイルをまだ提供していない。
532 必要な定義については
533 .I linux/ioprio.h
534 を見ればよい。
535 .\"O .SH "SEE ALSO"
536 .SH 関連項目
537 .BR getpriority (2),
538 .BR open (2),
539 .BR capabilities (7)
540 .sp
541 .\"O Documentation/block/ioprio.txt in the kernel source tree.
542 カーネル・ソース内の Documentation/block/ioprio.txt