[LTP] [PATCH 1/2] SAFE_MACROS: Add SAFE_SETPRIORITY() && Drop redundant space

Guangwen Feng fenggw-fnst@cn.fujitsu.com
Tue Nov 22 10:42:15 CET 2016


Hi Cyril,

Thanks for your review.

On 11/22/2016 04:09 PM, Cyril Hrubis wrote:
> Hi!
> I would rather see the whitespace cleanup in a separate patch. It's
> harder to track what changes were done in a patch if it combines
> unrelated changes.

OK, I will separate the patch and resend them.

> 
> And also this is 1/2, shouldn't there be a second patch that uses this?

Yes, I should have sent the second patch that uses this, but I faced a problem
below and was still working on it.

I found that setpriority01 with PRIO_USER as root will change system environment,
set the priorities of all specified processes to 19.

Before setpriority(PRIO_USER, root, -20..19):
[fenggw@localhost ~]$ ps -eo "%p %y %x %c %n"
  PID TTY          TIME COMMAND          NI
    1 ?        00:00:01 systemd           0
    2 ?        00:00:00 kthreadd          0
    3 ?        00:00:00 ksoftirqd/0       0
    5 ?        00:00:00 kworker/0:0H    -20
    7 ?        00:00:00 migration/0       -
    8 ?        00:00:00 rcu_bh            0
    9 ?        00:00:27 rcu_sched         0
   10 ?        00:00:00 watchdog/0        -
   11 ?        00:00:00 watchdog/1        -
   12 ?        00:00:00 migration/1       -
   13 ?        00:00:00 ksoftirqd/1       0
   15 ?        00:00:00 kworker/1:0H    -20
   16 ?        00:00:00 watchdog/2        -
   17 ?        00:00:00 migration/2       -
   18 ?        00:00:00 ksoftirqd/2       0
   20 ?        00:00:00 kworker/2:0H    -20
   21 ?        00:00:00 watchdog/3        -
   22 ?        00:00:00 migration/3       -
   23 ?        00:00:00 ksoftirqd/3       0
   25 ?        00:00:00 kworker/3:0H    -20
   26 ?        00:00:00 khelper         -20
   27 ?        00:00:00 kdevtmpfs         0
   28 ?        00:00:00 netns           -20
   29 ?        00:00:00 writeback       -20
   30 ?        00:00:00 kintegrityd     -20
   31 ?        00:00:00 bioset          -20
   32 ?        00:00:00 kblockd         -20
   33 ?        00:00:00 ata_sff         -20
   34 ?        00:00:00 khubd             0
   35 ?        00:00:00 md              -20
   60 ?        00:00:01 kswapd0           0
   61 ?        00:00:00 ksmd              5
   62 ?        00:00:00 khugepaged       19
   63 ?        00:00:00 fsnotify_mark     0
   64 ?        00:00:00 crypto          -20
   73 ?        00:00:00 kthrotld        -20
   76 ?        00:00:00 scsi_eh_0         0
   77 ?        00:00:00 scsi_eh_1         0
   78 ?        00:00:00 scsi_eh_2         0
   79 ?        00:00:00 scsi_eh_3         0
   83 ?        00:00:00 kpsmoused       -20
   85 ?        00:00:00 deferwq         -20
   86 ?        00:00:00 kworker/u8:5      0
   94 ?        00:00:00 kauditd           0
  198 ?        00:00:00 kworker/3:1H    -20
  199 ?        00:00:00 kworker/1:1H    -20
  200 ?        00:00:00 kworker/0:1H    -20
  205 ?        00:00:00 kworker/2:1H    -20
  218 ?        00:00:01 jbd2/sda2-8       0
  219 ?        00:00:00 ext4-rsv-conver -20
  220 ?        00:00:00 ext4-unrsv-conv -20
  283 ?        00:00:01 systemd-journal   0
  312 ?        00:00:00 lvmetad           0
  316 ?        00:00:00 rpciod          -20
  330 ?        00:00:00 systemd-udevd     0
  361 ?        00:00:00 irq/46-mei_me     -
  364 ?        00:00:00 kvm-irqfd-clean -20
  374 ?        00:00:00 hd-audio0       -20
  377 ?        00:00:00 hd-audio1       -20
  389 ?        00:00:00 jbd2/sda7-8       0
  390 ?        00:00:00 ext4-rsv-conver -20
  391 ?        00:00:00 ext4-unrsv-conv -20
  397 ?        00:00:00 jbd2/sda9-8       0
  398 ?        00:00:00 ext4-rsv-conver -20
  399 ?        00:00:00 ext4-unrsv-conv -20
  401 ?        00:00:00 jbd2/sda8-8       0
  402 ?        00:00:00 ext4-rsv-conver -20
  403 ?        00:00:00 ext4-unrsv-conv -20
  406 ?        00:00:00 jbd2/sda6-8       0
  407 ?        00:00:00 ext4-rsv-conver -20
  408 ?        00:00:00 ext4-unrsv-conv -20
  410 ?        00:00:00 jbd2/sda1-8       0
  411 ?        00:00:00 ext4-rsv-conver -20
  412 ?        00:00:00 ext4-unrsv-conv -20
  415 ?        00:00:00 jbd2/sda5-8       0
  416 ?        00:00:00 ext4-rsv-conver -20
  417 ?        00:00:00 ext4-unrsv-conv -20
  421 ?        00:00:00 auditd           -4
  431 ?        00:00:00 audispd          -8
  432 ?        00:00:00 sedispatch       -4
  443 ?        00:00:00 accounts-daemon   0
  447 ?        00:00:00 rtkit-daemon      1
  448 ?        00:00:00 avahi-daemon      0
  450 ?        00:00:03 NetworkManager    0
  454 ?        00:00:00 abrtd             0
  456 ?        00:00:21 rngd              0
  457 ?        00:00:00 abrt-watch-log    0
  458 ?        00:00:00 avahi-daemon      0
  460 ?        00:00:00 chronyd           0
  477 ?        00:00:00 cfg80211        -20
  480 ?        00:00:01 irqbalance        0
  481 ?        00:00:00 abrt-watch-log    0
  484 ?        00:00:00 smartd            0
  485 ?        00:00:00 ModemManager      0
  486 ?        00:00:00 systemd-logind    0
  487 ?        00:00:06 rsyslogd          0
  489 ?        00:00:05 dbus-daemon       0
  491 ?        00:00:00 mcelog            0
  493 ?        00:00:00 crond             0
  495 ?        00:00:00 atd               0
  510 ?        00:00:00 gdm               0
  532 ?        00:00:00 gdm-simple-slav   0
  544 tty1     00:05:51 Xorg              0
  563 ?        00:09:08 libvirtd          0
  567 ?        00:00:00 rpcbind           0
  579 ?        00:00:00 bluetoothd        0
  580 ?        00:00:06 nmbd              0
  581 ?        00:00:00 sshd              0
  593 ?        00:00:00 rpc.statd         0
  656 ?        00:00:00 systemd           0
  660 ?        00:00:00 (sd-pam)          0
  661 ?        00:00:00 smbd              0
  674 ?        00:00:00 smbd              0
  679 ?        00:00:00 cupsd             0
  701 ?        00:00:00 upowerd           0
  736 ?        00:00:00 colord            0
  738 ?        00:00:00 pcscd             0
  808 ?        00:00:00 dnsmasq           0
  860 ?        00:00:00 dhclient          0
  890 ?        00:00:00 gdm-session-wor   0
  895 ?        00:00:00 systemd           0
  897 ?        00:00:00 (sd-pam)          0
  899 ?        00:00:00 gnome-keyring-d   0
  901 ?        00:00:00 gnome-session     0
  909 ?        00:00:00 dbus-launch       0
  910 ?        00:00:02 dbus-daemon       0
  974 ?        00:00:00 gvfsd             0
  979 ?        00:00:00 gvfsd-fuse        0
 1062 ?        00:00:00 at-spi-bus-laun   0
 1066 ?        00:00:00 dbus-daemon       0
 1069 ?        00:00:00 at-spi2-registr   0
 1085 ?        00:00:02 gnome-settings-   0
 1092 ?        00:06:13 pulseaudio      -11
 1123 ?        00:00:00 gvfs-udisks2-vo   0
 1125 ?        00:00:05 udisksd           0
 1134 ?        00:00:00 gvfs-mtp-volume   0
 1138 ?        00:00:00 gvfs-goa-volume   0
 1141 ?        00:00:01 goa-daemon        0
 1147 ?        00:00:00 mission-control   0
 1151 ?        00:00:00 gvfs-gphoto2-vo   0
 1156 ?        00:00:00 gvfs-afc-volume   0
 1160 ?        00:07:05 gnome-shell       0
 1163 ?        00:00:00 dconf-service     0
 1187 ?        00:00:00 gsd-printer       0
 1215 ?        00:00:32 ibus-daemon       0
 1219 ?        00:00:00 ibus-dconf        0
 1221 ?        00:00:04 ibus-x11          0
 1240 ?        00:00:00 gnome-shell-cal   0
 1246 ?        00:00:00 evolution-sourc   0
 1291 ?        00:00:00 evolution-alarm   0
 1292 ?        00:04:06 tracker-miner-f  19
 1307 ?        00:02:53 tracker-store     0
 1316 ?        00:00:00 abrt-applet       0
 1328 ?        00:00:00 deja-dup-monito   0
 1364 ?        00:00:00 evolution-calen   0
 1395 ?        00:00:00 obexd             0
 1526 ?        00:00:03 ibus-engine-sim   0
 1532 ?        00:00:00 gvfsd-burn        0
 1551 ?        00:00:18 gnome-terminal-   0
 1557 ?        00:00:00 gnome-pty-helpe   0
 1558 pts/0    00:00:00 bash              0
 1585 pts/1    00:00:00 bash              0
 1612 pts/2    00:00:00 bash              0
 1639 pts/3    00:00:00 bash              0
 1666 pts/4    00:00:00 bash              0
 1693 pts/5    00:00:00 bash              0
 1720 pts/6    00:00:00 bash              0
 1834 ?        00:06:51 pidgin            0
 1852 ?        00:00:00 systemd           0
 1853 ?        00:00:00 (sd-pam)          0
 1989 pts/7    00:00:00 bash              0
 2016 pts/7    00:00:00 startup.sh        0
 2020 pts/7    00:00:56 java              0
 2042 ?        00:01:19 thunderbird       0
 3661 ?        00:00:00 gvfsd-metadata    0
 5903 ?        00:20:44 virt-manager      0
 5986 ?        00:00:00 systemd-machine   0
 6095 pts/0    00:00:00 su                0
 6099 pts/0    00:00:00 bash              0
 6253 ?        00:03:57 firefox           0
 6748 ?        00:00:00 nautilus          0
 6756 ?        00:00:01 gvfsd-trash       0
 6810 ?        00:02:49 wineserver        0
 6816 ?        00:00:00 services.exe      0
 6820 ?        00:00:00 winedevice.exe    0
 6829 ?        00:00:00 plugplay.exe      0
 6841 ?        00:00:00 rpcss.exe         0
 6885 ?        00:00:00 explorer.exe      0
 6887 ?        00:04:55 insight3.exe      0
 6897 pts/3    00:00:00 su                0
 6902 pts/3    00:00:00 bash              0
 6948 pts/4    00:00:00 su                0
 6953 pts/4    00:00:00 bash              0
 7139 ?        00:00:11 ibus-engine-lib   0
15015 ?        00:00:00 gconfd-2          0
19223 pts/6    00:00:00 su                0
19228 pts/6    00:00:00 bash              0
19251 pts/6    00:00:00 virsh             0
19389 ?        00:00:04 kworker/1:2       0
19670 pts/0    00:00:00 vim               0
20325 ?        00:00:04 kworker/0:1       0
22767 ?        00:04:23 qemu-system-x86   0
22768 ?        00:00:00 vhost-22767       0
22773 ?        00:00:00 kvm-pit/22767     0
23918 ?        00:00:00 kworker/u8:0      0
26647 ?        00:00:00 kworker/2:0       0
26860 ?        00:00:00 kworker/1:0       0
26875 ?        00:00:00 kworker/3:2       0
26886 ?        00:00:00 kworker/2:1       0
26929 ?        00:00:00 kworker/3:0       0
26946 ?        00:00:00 polkitd           0
27036 ?        00:00:00 kworker/0:2       0
27389 pts/4    00:00:00 man               0
27406 pts/4    00:00:00 less              0
27482 ?        00:00:00 kworker/2:2       0
27698 ?        00:00:00 kworker/3:1       0
27819 ?        00:00:00 kworker/1:1       0
27957 ?        00:00:00 gedit             0
27966 pts/2    00:00:00 ps                0


After setpriority(PRIO_USER, root, -20..19):
[fenggw@localhost ~]$ ps -eo "%p %y %x %c %n"
  PID TTY          TIME COMMAND          NI
    1 ?        00:00:01 systemd          19
    2 ?        00:00:00 kthreadd         19
    3 ?        00:00:00 ksoftirqd/0      19
    5 ?        00:00:00 kworker/0:0H     19
    7 ?        00:00:00 migration/0       -
    8 ?        00:00:00 rcu_bh           19
    9 ?        00:00:27 rcu_sched        19
   10 ?        00:00:00 watchdog/0        -
   11 ?        00:00:00 watchdog/1        -
   12 ?        00:00:00 migration/1       -
   13 ?        00:00:00 ksoftirqd/1      19
   15 ?        00:00:00 kworker/1:0H     19
   16 ?        00:00:00 watchdog/2        -
   17 ?        00:00:00 migration/2       -
   18 ?        00:00:00 ksoftirqd/2      19
   20 ?        00:00:00 kworker/2:0H     19
   21 ?        00:00:00 watchdog/3        -
   22 ?        00:00:00 migration/3       -
   23 ?        00:00:00 ksoftirqd/3      19
   25 ?        00:00:00 kworker/3:0H     19
   26 ?        00:00:00 khelper          19
   27 ?        00:00:00 kdevtmpfs        19
   28 ?        00:00:00 netns            19
   29 ?        00:00:00 writeback        19
   30 ?        00:00:00 kintegrityd      19
   31 ?        00:00:00 bioset           19
   32 ?        00:00:00 kblockd          19
   33 ?        00:00:00 ata_sff          19
   34 ?        00:00:00 khubd            19
   35 ?        00:00:00 md               19
   60 ?        00:00:01 kswapd0          19
   61 ?        00:00:00 ksmd             19
   62 ?        00:00:00 khugepaged       19
   63 ?        00:00:00 fsnotify_mark    19
   64 ?        00:00:00 crypto           19
   73 ?        00:00:00 kthrotld         19
   76 ?        00:00:00 scsi_eh_0        19
   77 ?        00:00:00 scsi_eh_1        19
   78 ?        00:00:00 scsi_eh_2        19
   79 ?        00:00:00 scsi_eh_3        19
   83 ?        00:00:00 kpsmoused        19
   85 ?        00:00:00 deferwq          19
   86 ?        00:00:00 kworker/u8:5     19
   94 ?        00:00:00 kauditd          19
  198 ?        00:00:00 kworker/3:1H     19
  199 ?        00:00:00 kworker/1:1H     19
  200 ?        00:00:00 kworker/0:1H     19
  205 ?        00:00:00 kworker/2:1H     19
  218 ?        00:00:01 jbd2/sda2-8      19
  219 ?        00:00:00 ext4-rsv-conver  19
  220 ?        00:00:00 ext4-unrsv-conv  19
  283 ?        00:00:01 systemd-journal  19
  312 ?        00:00:00 lvmetad          19
  316 ?        00:00:00 rpciod           19
  330 ?        00:00:00 systemd-udevd    19
  361 ?        00:00:00 irq/46-mei_me     -
  364 ?        00:00:00 kvm-irqfd-clean  19
  374 ?        00:00:00 hd-audio0        19
  377 ?        00:00:00 hd-audio1        19
  389 ?        00:00:00 jbd2/sda7-8      19
  390 ?        00:00:00 ext4-rsv-conver  19
  391 ?        00:00:00 ext4-unrsv-conv  19
  397 ?        00:00:00 jbd2/sda9-8      19
  398 ?        00:00:00 ext4-rsv-conver  19
  399 ?        00:00:00 ext4-unrsv-conv  19
  401 ?        00:00:00 jbd2/sda8-8      19
  402 ?        00:00:00 ext4-rsv-conver  19
  403 ?        00:00:00 ext4-unrsv-conv  19
  406 ?        00:00:00 jbd2/sda6-8      19
  407 ?        00:00:00 ext4-rsv-conver  19
  408 ?        00:00:00 ext4-unrsv-conv  19
  410 ?        00:00:00 jbd2/sda1-8      19
  411 ?        00:00:00 ext4-rsv-conver  19
  412 ?        00:00:00 ext4-unrsv-conv  19
  415 ?        00:00:00 jbd2/sda5-8      19
  416 ?        00:00:00 ext4-rsv-conver  19
  417 ?        00:00:00 ext4-unrsv-conv  19
  421 ?        00:00:00 auditd           19
  431 ?        00:00:00 audispd          19
  432 ?        00:00:00 sedispatch       19
  443 ?        00:00:00 accounts-daemon  19
  447 ?        00:00:00 rtkit-daemon      1
  448 ?        00:00:00 avahi-daemon      0
  450 ?        00:00:03 NetworkManager   19
  454 ?        00:00:00 abrtd            19
  456 ?        00:00:22 rngd             19
  457 ?        00:00:00 abrt-watch-log   19
  458 ?        00:00:00 avahi-daemon      0
  460 ?        00:00:00 chronyd           0
  477 ?        00:00:00 cfg80211         19
  480 ?        00:00:01 irqbalance       19
  481 ?        00:00:00 abrt-watch-log   19
  484 ?        00:00:00 smartd           19
  485 ?        00:00:00 ModemManager     19
  486 ?        00:00:00 systemd-logind   19
  487 ?        00:00:06 rsyslogd         19
  489 ?        00:00:05 dbus-daemon       0
  491 ?        00:00:00 mcelog           19
  493 ?        00:00:00 crond            19
  495 ?        00:00:00 atd              19
  510 ?        00:00:00 gdm              19
  532 ?        00:00:00 gdm-simple-slav  19
  544 tty1     00:05:52 Xorg             19
  563 ?        00:09:09 libvirtd         19
  567 ?        00:00:00 rpcbind           0
  579 ?        00:00:00 bluetoothd       19
  580 ?        00:00:06 nmbd             19
  581 ?        00:00:00 sshd             19
  593 ?        00:00:00 rpc.statd         0
  656 ?        00:00:00 systemd           0
  660 ?        00:00:00 (sd-pam)          0
  661 ?        00:00:00 smbd             19
  674 ?        00:00:00 smbd             19
  679 ?        00:00:00 cupsd            19
  701 ?        00:00:00 upowerd          19
  736 ?        00:00:00 colord            0
  738 ?        00:00:00 pcscd            19
  808 ?        00:00:00 dnsmasq           0
  860 ?        00:00:00 dhclient         19
  890 ?        00:00:00 gdm-session-wor  19
  895 ?        00:00:00 systemd           0
  897 ?        00:00:00 (sd-pam)          0
  899 ?        00:00:00 gnome-keyring-d   0
  901 ?        00:00:00 gnome-session     0
  909 ?        00:00:00 dbus-launch       0
  910 ?        00:00:02 dbus-daemon       0
  974 ?        00:00:00 gvfsd             0
  979 ?        00:00:00 gvfsd-fuse        0
 1062 ?        00:00:00 at-spi-bus-laun   0
 1066 ?        00:00:00 dbus-daemon       0
 1069 ?        00:00:00 at-spi2-registr   0
 1085 ?        00:00:02 gnome-settings-   0
 1092 ?        00:06:15 pulseaudio      -11
 1123 ?        00:00:00 gvfs-udisks2-vo   0
 1125 ?        00:00:05 udisksd          19
 1134 ?        00:00:00 gvfs-mtp-volume   0
 1138 ?        00:00:00 gvfs-goa-volume   0
 1141 ?        00:00:01 goa-daemon        0
 1147 ?        00:00:00 mission-control   0
 1151 ?        00:00:00 gvfs-gphoto2-vo   0
 1156 ?        00:00:00 gvfs-afc-volume   0
 1160 ?        00:07:08 gnome-shell       0
 1163 ?        00:00:00 dconf-service     0
 1187 ?        00:00:00 gsd-printer       0
 1215 ?        00:00:32 ibus-daemon       0
 1219 ?        00:00:00 ibus-dconf        0
 1221 ?        00:00:04 ibus-x11          0
 1240 ?        00:00:00 gnome-shell-cal   0
 1246 ?        00:00:00 evolution-sourc   0
 1291 ?        00:00:00 evolution-alarm   0
 1292 ?        00:04:06 tracker-miner-f  19
 1307 ?        00:02:53 tracker-store     0
 1316 ?        00:00:00 abrt-applet       0
 1328 ?        00:00:00 deja-dup-monito   0
 1364 ?        00:00:00 evolution-calen   0
 1395 ?        00:00:00 obexd             0
 1526 ?        00:00:03 ibus-engine-sim   0
 1532 ?        00:00:00 gvfsd-burn        0
 1551 ?        00:00:19 gnome-terminal-   0
 1557 ?        00:00:00 gnome-pty-helpe   0
 1558 pts/0    00:00:00 bash              0
 1585 pts/1    00:00:00 bash              0
 1612 pts/2    00:00:00 bash              0
 1639 pts/3    00:00:00 bash              0
 1666 pts/4    00:00:00 bash              0
 1693 pts/5    00:00:00 bash              0
 1720 pts/6    00:00:00 bash              0
 1834 ?        00:06:53 pidgin            0
 1852 ?        00:00:00 systemd          19
 1853 ?        00:00:00 (sd-pam)         19
 1989 pts/7    00:00:00 bash              0
 2016 pts/7    00:00:00 startup.sh        0
 2020 pts/7    00:00:56 java              0
 2042 ?        00:01:19 thunderbird       0
 3661 ?        00:00:00 gvfsd-metadata    0
 5903 ?        00:20:47 virt-manager      0
 5986 ?        00:00:00 systemd-machine  19
 6095 pts/0    00:00:00 su                0
 6099 pts/0    00:00:00 bash             19
 6253 ?        00:03:58 firefox           0
 6748 ?        00:00:00 nautilus          0
 6756 ?        00:00:01 gvfsd-trash       0
 6810 ?        00:02:50 wineserver        0
 6816 ?        00:00:00 services.exe      0
 6820 ?        00:00:00 winedevice.exe    0
 6829 ?        00:00:00 plugplay.exe      0
 6841 ?        00:00:00 rpcss.exe         0
 6885 ?        00:00:00 explorer.exe      0
 6887 ?        00:04:55 insight3.exe      0
 6897 pts/3    00:00:00 su                0
 6902 pts/3    00:00:00 bash             19
 6948 pts/4    00:00:00 su                0
 6953 pts/4    00:00:00 bash             19
 7139 ?        00:00:11 ibus-engine-lib   0
15015 ?        00:00:00 gconfd-2          0
19223 pts/6    00:00:00 su                0
19228 pts/6    00:00:00 bash             19
19251 pts/6    00:00:00 virsh            19
19389 ?        00:00:04 kworker/1:2      19
19670 pts/0    00:00:00 vim              19
20325 ?        00:00:04 kworker/0:1      19
22767 ?        00:04:25 qemu-system-x86   0
22768 ?        00:00:00 vhost-22767      19
22773 ?        00:00:00 kvm-pit/22767    19
23918 ?        00:00:00 kworker/u8:0     19
26647 ?        00:00:01 kworker/2:0      19
26860 ?        00:00:00 kworker/1:0      19
26875 ?        00:00:00 kworker/3:2      19
26886 ?        00:00:00 kworker/2:1      19
26929 ?        00:00:00 kworker/3:0      19
26946 ?        00:00:00 polkitd           0
27036 ?        00:00:00 kworker/0:2      19
27389 pts/4    00:00:00 man              19
27406 pts/4    00:00:00 less             19
27482 ?        00:00:00 kworker/2:2      19
27698 ?        00:00:00 kworker/3:1      19
27819 ?        00:00:00 kworker/1:1      19
27957 ?        00:00:00 gedit             0
28172 pts/1    00:00:00 su                0
28173 ?        00:00:00 fprintd          19
28177 pts/1    00:00:00 bash             19
28328 pts/2    00:00:00 ps                0

Best Regards,
Guangwen Feng




More information about the ltp mailing list