• Thomas Richter's avatar
    s390/con3215: Drop console data printout when buffer full · 1f3307cf
    Thomas Richter authored
    Using z/VM the 3270 terminal emulator also emulates an IBM 3215 console
    which outputs line by line. When the screen is full, the console enters
    the MORE... state and waits for the operator to confirm the data
    on the screen by pressing a clear key. If this does not happen in the
    default time frame (currently 50 seconds) the console enters the HOLDING
    state.
    It then waits another time frame (currently 10 seconds) before the output
    continues on the next screen. When the operator presses the clear key
    during these wait times, the output continues immediately.
    
    This may lead to a very long boot time when the console
    has to print many messages, also the system may hang because of the
    console's limited buffer space and the system waits for the console
    output to drain and finally to finish. This problem can only occur
    when a terminal emulator is actually connected to the 3215 console
    driver. If not z/VM simply drops console output.
    
    Remedy this rare situation and add a kernel boot command line parameter
    con3215_drop. It can be set to 0 (do not drop) or 1 (do drop) which is
    the default. This instructs the kernel drop console data when the
    console buffer is full. This speeds up the boot time considerable and
    also does not hang the system anymore.
    
    Add a sysfs attribute file for console IBM 3215 named con_drop.
    This allows for changing the behavior after the boot, for example when
    during interactive debugging a panic/crash is expected.
    
    Here is a test of the new behavior using the following test program:
     #/bin/bash
     declare -i cnt=4
    
     mode=$(cat /sys/bus/ccw/drivers/3215/con_drop)
     [ $mode = yes ] && cnt=25
    
     echo "cons_drop $(cat /sys/bus/ccw/drivers/3215/con_drop)"
     echo "vmcp term more 5 2"
     vmcp term more 5 2
     echo "Run $cnt iterations of "'echo t > /proc/sysrq-trigger'
    
     for i in $(seq $cnt)
     do
    	echo "$i. command 'echo t > /proc/sysrq-trigger' at $(date +%F,%T)"
    	echo t > /proc/sysrq-trigger
    	sleep 1
     done
     echo "droptest done" > /dev/kmsg
     #
    
    Output with sysfs attribute con_drop set to 1:
     # ./droptest.sh
     cons_drop yes
     vmcp term more 5 2
     Run 25 iterations of echo t > /proc/sysrq-trigger
     1. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:09
     2. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:10
     3. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:11
     4. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:12
     5. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:13
     6. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:14
     7. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:15
     8. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:16
     9. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:17
     10. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:18
     11. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:19
     12. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:20
     13. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:21
     14. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:22
     15. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:23
     16. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:24
     17. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:25
     18. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:26
     19. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:27
     20. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:28
     21. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:29
     22. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:30
     23. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:31
     24. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:32
     25. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:15:33
     #
    
    There are no hangs anymore.
    
    Output with sysfs attribute con_drop set to 0 and identical
    setting for z/VM console 'term more 5 2'. Sometimes hitting the
    clear key at the x3270 console to progress output.
    
     # ./droptest.sh
     cons_drop no
     vmcp term more 5 2
     Run 4 iterations of echo t > /proc/sysrq-trigger
     1. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:20:58
     2. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:24:32
     3. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:28:04
     4. command 'echo t > /proc/sysrq-trigger' at 2022-09-02,10:31:37
     #
    
    Details:
    Enable function raw3215_write() to handle tab expansion and newlines
    and feed it with input not larger than the console buffer of 65536
    bytes. Function raw3125_putchar() just forwards its character for
    output to raw3215_write().
    
    This moves tab to blank conversion to one function raw3215_write()
    which also does call raw3215_make_room() to wait for enough free
    buffer space.
    
    Function handle_write() loops over all its input and segments input
    into chunks of console buffer size (should the input be larger).
    
    Rework tab expansion handling logic to avoid code duplication.
    Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
    Acked-by: default avatarPeter Oberparleiter <oberpar@linux.ibm.com>
    Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
    Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
    1f3307cf
con3215.c 29.7 KB