From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1B1BC433E1 for ; Tue, 11 Aug 2020 08:10:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C14D520578 for ; Tue, 11 Aug 2020 08:10:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ReZHC+SF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728225AbgHKIKn (ORCPT ); Tue, 11 Aug 2020 04:10:43 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:33690 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727998AbgHKIKn (ORCPT ); Tue, 11 Aug 2020 04:10:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597133442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ETM5SVJgSYa28QAQrXzkvKzwfyNa1RWXhMMsF/tbcjU=; b=ReZHC+SFw30c1koZqsu6d1BFNkMMfcHigtyBUNSi5rJbCTquwWk4Q9/VWxQju4brRw6Sve lfePjBeGFNBdA7i0K8XhG/MM+y35MK3zo9/5KWkRBmYfwDaFVC+EoKS1q0sAFk6mWI6ihC eMjkTwk7Gtf9SvsvkyGuPjL6b1PWo5E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-H20mh8tYNymRfg1oA-_Fkw-1; Tue, 11 Aug 2020 04:10:38 -0400 X-MC-Unique: H20mh8tYNymRfg1oA-_Fkw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 01C998015F0; Tue, 11 Aug 2020 08:10:37 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.186]) by smtp.corp.redhat.com (Postfix) with SMTP id 547D617B9B; Tue, 11 Aug 2020 08:10:35 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 11 Aug 2020 10:10:36 +0200 (CEST) Date: Tue, 11 Aug 2020 10:10:34 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: Jann Horn , Jens Axboe , io-uring , stable , Josef Subject: Re: [PATCH 2/2] io_uring: use TWA_SIGNAL for task_work if the task isn't running Message-ID: <20200811081033.GD21797@redhat.com> References: <20200810211057.GG3982@worktop.programming.kicks-ass.net> <5628f79b-6bfb-b054-742a-282663cb2565@kernel.dk> <1629f8a9-cee0-75f1-810a-af32968c4055@kernel.dk> <20200811064516.GA21797@redhat.com> <20200811065659.GQ3982@worktop.programming.kicks-ass.net> <20200811071401.GB21797@redhat.com> <20200811074538.GS3982@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200811074538.GS3982@worktop.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On 08/11, Peter Zijlstra wrote: > > On Tue, Aug 11, 2020 at 09:14:02AM +0200, Oleg Nesterov wrote: > > On 08/11, Peter Zijlstra wrote: > > > > > > On Tue, Aug 11, 2020 at 08:45:16AM +0200, Oleg Nesterov wrote: > > > > > > > > ->jobctl is always modified with ->siglock held, do we really need > > > > WRITE_ONCE() ? > > > > > > In theory, yes. The compiler doesn't know about locks, it can tear > > > writes whenever it feels like it. > > > > Yes, but why does this matter? Could you spell please? > > Ah, well, that I don't konw. Why do we need the READ_ONCE() ? > > It does: > > > + if (!(task->jobctl & JOBCTL_TASK_WORK) && > > + lock_task_sighand(task, &flags)) { > > and the lock_task_sighand() implies barrier(), so I thought the reason > for the READ_ONCE() was load-tearing, and then we need WRITE_ONCE() to > avoid store-tearing. I don't think we really need READ_ONCE() for correctness, compiler can't reorder this LOAD with cmpxchg() above, and I think we don't care about load-tearing. But I guess we need READ_ONCE() or data_race() to shut kcsan up. Oleg.