Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1734936

Re: [PATCH 3/3] kcov: remove useless barrier()s

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Dmitry Vyukov <dvyukov@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH 3/3] kcov: remove useless barrier()s
Date Tue, 19 Sep 2017 16:00:02 +0200
Message-ID <urrea-69k-23@gated-at.bofh.it> (permalink)
References <urqi5-5B6-3@gated-at.bofh.it> <urqi6-5B6-23@gated-at.bofh.it> <urqi6-5B6-21@gated-at.bofh.it> <urrea-69k-25@gated-at.bofh.it>
X-Original-To Andrey Ryabinin <aryabinin@virtuozzo.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Wkm+cEj8LMSOgIJgdvud+2FYbOHetgrigORfcqYQ5bE=; b=IECexx8W9UwSVnVwKjct7gjxUhPJnVSJbo7xYqPqH2wZKZ2SNT09aWYJtZcxP03du6 878b1+hGCMAc9/IqBMl8pDjgqs6nGMo72IQ7549bv+o0C88auxAwtk9+wFfQBw8CSZRX oXKyblyS4wX4BG7eBF6YC3IKiAwZhgEz6z+sImEswLxCAWK86hRt82GLU/Ub5p7DDyAf QcLV5rib/GeMX6n7ZMM3yNBFUxl3Zsktcu6IoXOMK0/eN3ppOz7BGsUTnBu7Wc+DL5HV 2wQBjZwUmoAxqk4PhBLVNzdQHOSQ8tt7j5/+YSYtms/6xQFFP/mmAGvyA5f5buysIPpp 87zg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Wkm+cEj8LMSOgIJgdvud+2FYbOHetgrigORfcqYQ5bE=; b=TBZ3oFNl76KSK5vlNe02ZbBU650colZg0Xc3sh+cWzqpHWCmcdPsq2znhua3sawDPz lUSsqrCZZGJ9O3Qw445O56ZiEablGQFQ516QOB6g6b/hZe+rdK9D4w6GwWALwfXZfuSs lWIsd9Lh9PksDduOdEF5hwtyqs96u75+JLXY+BsWdDG6NAJYWg5IgD5YOZUVhseEgRV0 awaQiUI4idLkGsDoXOFUBPtS9KRd1XgMevfJG1uPQXUcSsUMi47w9gHRjWLA3puTXgi7 prOWz8km2SaOGiRQ7ZiayY03A6M9fcMrF+8vpRSQGLrfaNcdZeOWM6ZD8IAdzvQA0/iI kuhA==
X-Gm-Message-State AHPjjUhLL8eqX99XEeZNsXQR0CwbRGUmRQOXIlPFPm5mwk02Usuy/d+E ohEhmtv4/RB0T/orPr3eTLYqRaNFw4+mFfBnk1A/JQ==
X-Google-SMTP-Source AOwi7QC8cI02R+I6HdiuneiAI4Clf+focWxOnZZYXSE5842RQZPqedDtRYE+jeKh9zARQkTtT97CuFirh1oXOkd1oO8=
X-Received by 10.107.55.8 with SMTP id e8mr2267465ioa.166.1505829266966; Tue, 19 Sep 2017 06:54:26 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 74
Organization linux.* mail to news gateway
X-Original-Cc Andrew Morton <akpm@linux-foundation.org>, Andrey Konovalov <andreyknvl@google.com>, Victor Chibotaru <tchibo@google.com>, syzkaller <syzkaller@googlegroups.com>, Mark Rutland <mark.rutland@arm.com>, LKML <linux-kernel@vger.kernel.org>
X-Original-Date Tue, 19 Sep 2017 15:54:06 +0200
X-Original-Message-ID <CACT4Y+bv6E_DLYEdF0yBC69=gNV++CS7AzN28-jPYoH6JWNdeQ@mail.gmail.com>
X-Original-References <20170919124648.28963-1-aryabinin@virtuozzo.com> <20170919124648.28963-3-aryabinin@virtuozzo.com> <CACT4Y+YR6VZ7Wncarq4W+2B6XLPMxipMesSLbcbt+4XwEU58pA@mail.gmail.com> <aa6f5593-0d6e-cfad-6ca6-3b5919cbe507@virtuozzo.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1734936

Show key headers only | View raw


On Tue, Sep 19, 2017 at 3:52 PM, Andrey Ryabinin
<aryabinin@virtuozzo.com> wrote:
>
>
> On 09/19/2017 03:57 PM, Dmitry Vyukov wrote:
>> On Tue, Sep 19, 2017 at 2:46 PM, Andrey Ryabinin
>> <aryabinin@virtuozzo.com> wrote:
>>> As comment says barriers needed for preempt_schedule_irq() case
>>> where in_interrupt() returns false. But we don't use in_interrupt()
>>> since b274c0bb394c ("kcov: properly check if we are in an interrupt").
>>>
>>> Now we use in_task() which handles preempt_schedule_irq() case properly,
>>> thus no barrier required.
>>
>>
>> Are you sure in_task() handles preempt_schedule_irq() correctly?
>> They seem to differ only by SOFTIRQ_MASK vs SOFTIRQ_OFFSET, and that
>> only differs in local_bh_disable sections. But preempt_schedule_irq()
>> does not seem to have anything to do softirq/local_bh_disable. It's
>> called from real interrupts, right? So I would expect that in_task()
>> returns true in preempt_schedule_irq().
>
> Indeed, you're right. I checked this only on !PREEMPT kernel, where this worked.
>
> Still, I think that barrier() in __sanitizer_cov_trace_pc() is not needed. AFAIU it needed
> to make sure that load of t->kcov_area isn't moved before load of t->kcov_mode, but I don't
> think that compiler is allowed to make such reorder. That would be a bug in the compiler.


Why? C compiler is allowed to fuse/reorder loads from the same base
object. Also stores can be reordered.


>>> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>>> ---
>>>  kernel/kcov.c | 10 ----------
>>>  1 file changed, 10 deletions(-)
>>>
>>> diff --git a/kernel/kcov.c b/kernel/kcov.c
>>> index 14cc8c1a7cad..b7fbcbef88c1 100644
>>> --- a/kernel/kcov.c
>>> +++ b/kernel/kcov.c
>>> @@ -71,14 +71,6 @@ void notrace __sanitizer_cov_trace_pc(void)
>>>
>>>                 ip -= kaslr_offset();
>>>
>>> -               /*
>>> -                * There is some code that runs in interrupts but for which
>>> -                * in_interrupt() returns false (e.g. preempt_schedule_irq()).
>>> -                * READ_ONCE()/barrier() effectively provides load-acquire wrt
>>> -                * interrupts, there are paired barrier()/WRITE_ONCE() in
>>> -                * kcov_ioctl_locked().
>>> -                */
>>> -               barrier();
>>>                 area = t->kcov_area;
>>>                 /* The first word is number of subsequent PCs. */
>>>                 pos = READ_ONCE(area[0]) + 1;
>>> @@ -228,8 +220,6 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd,
>>>                 /* Cache in task struct for performance. */
>>>                 t->kcov_size = kcov->size;
>>>                 t->kcov_area = kcov->area;
>>> -               /* See comment in __sanitizer_cov_trace_pc(). */
>>> -               barrier();
>>>                 WRITE_ONCE(t->kcov_mode, kcov->mode);
>>>                 t->kcov = kcov;
>>>                 kcov->t = t;
>>> --
>>> 2.13.5
>>>
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 3/3] kcov: remove useless barrier()s Dmitry Vyukov <dvyukov@google.com> - 2017-09-19 15:00 +0200
  Re: [PATCH 3/3] kcov: remove useless barrier()s Dmitry Vyukov <dvyukov@google.com> - 2017-09-19 16:00 +0200
    Re: [PATCH 3/3] kcov: remove useless barrier()s Dmitry Vyukov <dvyukov@google.com> - 2017-09-19 16:50 +0200

csiph-web