Commit Graph

27 Commits

Author SHA1 Message Date
Thomas Schoebel-Theuer
7c59774177 copy: safeguard writeout flag 2023-08-07 16:08:55 +02:00
Thomas Schoebel-Theuer
49c408cac2 copy: constify state table subpages
I have seen some "strange" behaviour so infrequently, so I am unsure whether
this is a bugfix at all.

I am unsure, whether this _suspected_ bug would be in gcc, or whether
the bug would be mine.

If it is mine, then I assumed that gcc would produce better machine code
than required by ISO C.

Currently, I don't (yet) have the newest version of the ISO C standard,
so I cannot claim the truth.

Whatever: I found the _suspected_ bug by _dissassembling_ before vs after this
patch had been applied:

        .type   copy_brick_construct, @function                                                                 .type   copy_brick_construct, @function
copy_brick_construct:                                                                                   copy_brick_construct:
                                                                                                   >            pushq   %r13    #
        pushq   %r12    #                                                                                       pushq   %r12    #
        pushq   %rbp    #                                                                          |    # block/mars/kernel/mars_copy.c:        st = brick_block_alloc(0, PAGE_SIZE);
        movl    $1155, %edx     #,                                                                 <
                                                                                                   >            pushq   %rbp    #
        pushq   %rbx    #                                                                                       pushq   %rbx    #
        movl    $4096, %esi     #,                                                                 <
        movq    %rdi, %rbx      # brick, brick                                                     |            movq    %rdi, %r12      # brick, brick
                                                                                                   >            movl    $4096, %esi     #,
        xorl    %edi, %edi      #                                                                               xorl    %edi, %edi      #
        call    _brick_block_alloc      #                                                                       call    _brick_block_alloc      #
        movq    %rax, %rdx      #, tmp99                                                           |            movq    %rax, %rbx      #, _res_
        movl    $1024, %ecx     #, tmp102                                                                       movl    $1024, %ecx     #, tmp102
        movq    %rax, 408(%rbx) # tmp99, brick_11(D)->st                                           <
        movq    %rdx, %rdi      # tmp99, tmp99                                                     <
        xorl    %eax, %eax      # tmp101                                                                        xorl    %eax, %eax      # tmp101
        xorl    %ebp, %ebp      # ivtmp.179                                                        |            movq    %rbx, %rdi      # _res_, _res_
        xorl    %r12d, %r12d    # tmp106                                                           <
        rep stosl                                                                                               rep stosl
                                                                                                   >            xorl    %ebp, %ebp      # ivtmp.174
                                                                                                   >            xorl    %r13d, %r13d    # tmp105
.L26:                                                                                                   .L26:
        movl    $1172, %edx     #,                                                                 |            movl    $1177, %edx     #,
        movl    $4096, %esi     #,                                                                              movl    $4096, %esi     #,
        xorl    %edi, %edi      #                                                                               xorl    %edi, %edi      #
        call    _brick_block_alloc      #                                                                       call    _brick_block_alloc      #
        movq    %rax, %rdx      #, tmp103                                                                       movq    %rax, %rdx      #, tmp103
        movq    408(%rbx), %rax # brick_11(D)->st, brick_11(D)->st                                 |            movq    %rdx, (%rbx,%rbp,8)     # tmp103, MEM[base: _res__9, index: ivtmp.174_28, step:
                                                                                                   >            incq    %rbp    # ivtmp.174
        movl    $1024, %ecx     #, tmp107                                                          |            movq    %rax, %rdi      # tmp103, _res_
        movq    %rdx, %rdi      # tmp103, tmp103                                                   |            movl    $1024, %ecx     #, tmp106
        movq    %rdx, (%rax,%rbp)       # tmp103, *_4                                              <
        addq    $8, %rbp        #, ivtmp.179                                                       <
        movl    %r12d, %eax     # tmp106, tmp106                                                   <
        cmpq    $2048, %rbp     #, ivtmp.179                                                       |            cmpq    $256, %rbp      #, ivtmp.174
        rep stosl                                                                                               rep stosl
        jne     .L26    #,                                                                                      jne     .L26    #,
        leaq    376(%rbx), %rdi #, tmp108                                                          |            leaq    376(%r12), %rdi #, tmp107
        movq    $__key.72209, %rdx      #,                                                         |            movq    $__key.72227, %rdx      #,
        movq    $.LC3, %rsi     #,                                                                              movq    $.LC3, %rsi     #,
        call    __init_waitqueue_head   #                                                                       call    __init_waitqueue_head   #
                                                                                                   >    # block/mars/kernel/mars_copy.c:        brick->st = st;
                                                                                                   >            movq    %rbx, 408(%r12) # _res_, brick_10(D)->st
        xorl    %eax, %eax      #                                                                               xorl    %eax, %eax      #
        popq    %rbx    #                                                                                       popq    %rbx    #
        popq    %rbp    #                                                                                       popq    %rbp    #
        popq    %r12    #                                                                                       popq    %r12    #
                                                                                                   >            popq    %r13    #
        ret                                                                                                     ret

Hint: the 2-dimenional array indexing looks _suspicious_ to me.

But analysis is not as easy as one might assume.

Please help me:

If this would be really a bug in gcc (I am not sure), it should be fixed
by the upstream of gcc. Please contact me if you know / can show that

  (a) if it is _really_ a bug (currently very hard to reproduce via MARS), and
  (b) the bug is really in gcc but not mine (unsure for now), and
  (c) how to convert this into a _reproducer_ for the gcc team.

I am not sure whether this is a _full_ reproducer, because it might
depend on the arch (amd64) and/or on specific Linux kernel compile options.

I don't have the time for ananlysis of all of these, or maybe even more
thingies to do.
2023-08-07 16:08:55 +02:00
Thomas Schoebel-Theuer
d41ea13d37 copy: reduce clash overhead 2023-05-30 10:05:30 +02:00
Thomas Schoebel-Theuer
5a6cfa7798 copy: replace st->prev with computation 2022-12-02 22:17:36 +01:00
Thomas Schoebel-Theuer
9804d7456e copy: v2 stable_copy{start,end} 2022-12-02 22:17:36 +01:00
Thomas Schoebel-Theuer
5efeb7545b copy: length and offset paranoia for debugging 2022-12-02 22:17:36 +01:00
Thomas Schoebel-Theuer
a72af6a9e3 copy: introduce brick shutdown phase with timeout 2022-12-02 22:17:33 +01:00
Thomas Schoebel-Theuer
40651f0646 copy: index paranoia 2022-05-20 00:16:28 +02:00
Thomas Schoebel-Theuer
0615ab3a23 copy: fix enum type checking
block/mars/kernel/mars_copy.c:466:2: warning: case label value is less than minimum value for type [-Wswitch-outside-range]
2022-04-02 18:55:19 +02:00
Thomas Schoebel-Theuer
d18290d1f9 copy: remove redundant inputs 2021-07-15 11:20:51 +02:00
Thomas Schoebel-Theuer
8412411390 copy: make offset and len unsigned 2021-04-16 11:30:12 +02:00
Thomas Schoebel-Theuer
89c29da9c5 copy: safeguard queue deref 2021-04-16 11:30:12 +02:00
Thomas Schoebel-Theuer
222f048937 all: adapt to new timespec64 type 2019-12-25 09:19:07 +01:00
Thomas Schoebel-Theuer
a6fbb93394 copy: fix race on shutdown 2019-02-12 11:27:40 +01:00
Thomas Schoebel-Theuer
0da44a808f copy: allow non-strict write order 2017-05-28 19:20:26 +02:00
Thomas Schoebel-Theuer
a5247b7304 copy: do hinting per input 2017-04-11 09:27:58 +02:00
Thomas Schoebel-Theuer
7e2de9c4ac copy: speed up by hinting 2017-04-11 09:27:51 +02:00
Thomas Schoebel-Theuer
eadd8e3e61 copy: remember dirty area 2017-04-11 09:27:50 +02:00
Thomas Schoebel-Theuer
b6d4b69be8 copy: remove obsolete mutex 2017-04-11 09:27:50 +02:00
Thomas Schoebel-Theuer
71bc90cc71 copy: make fly limitation global 2017-04-11 09:18:30 +02:00
Thomas Schoebel-Theuer
d1988b3d7c copy: leave lifelock when EOF position decreases 2017-04-04 08:03:09 +02:00
Thomas Schoebel-Theuer
aa09d7df30 all: clarify license GPLv2+ 2014-11-25 18:09:17 +01:00
Thomas Schoebel-Theuer
7697826b5d copy: add timestamp of last advance 2014-03-19 17:49:39 +01:00
Thomas Schoebel-Theuer
c877c43eff copy: limit IO parallelism via /proc 2013-07-22 09:15:53 +02:00
Thomas Schoebel-Theuer
72a2537c6d copy: make io_prio configurable via /proc 2013-07-22 08:44:03 +02:00
Thomas Schoebel-Theuer
be412e736d copy: avoid higher-order pages for state tables 2013-04-15 18:37:12 +02:00
Thomas Schoebel-Theuer
c58417d271 all: move kernel source into separate directory 2013-04-08 17:01:37 +02:00