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.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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 04E51C433DF for ; Tue, 11 Aug 2020 13:06:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8FC22076C for ; Tue, 11 Aug 2020 13:06:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="TAj+vpG8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728566AbgHKNGZ (ORCPT ); Tue, 11 Aug 2020 09:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728526AbgHKNGY (ORCPT ); Tue, 11 Aug 2020 09:06:24 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B47C0C061787 for ; Tue, 11 Aug 2020 06:06:24 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id q19so438259pll.0 for ; Tue, 11 Aug 2020 06:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kqgrbgaDbYSWjzibEGpg4nka7M4G8sEc7lFMN/sJpKA=; b=TAj+vpG8IS8cYJZ+IAY60l/htOSbR/qIZUhksnHHgX1FY4pOQtEY6CFi3HC48NXtyS NjccgTp+0FfL6tKvJkV+CXOYGcPH1uJcAp87SthFqpFLosxVqQHGLOfYnP/9VmugagWs OoN7Rn9rlcwKOBvCXgkzaw/OZ/YyjaFTEyWEKcJJwRLl+TMddPW+JoZuIHTKgZ+wUbtT kjqbsdBzEAXN71Vj1po7VpOrS0qyftbn2GQ/WkVB2cjPfW+Bb2yU7YvfV0HVGzJrf4pE FYFhD8AlZ/wJPKWS5o4/a6rRnRxOYGyii5+f44/z38Qyi3zKFJWX7eHgT4OUnUUMF7Te oE2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kqgrbgaDbYSWjzibEGpg4nka7M4G8sEc7lFMN/sJpKA=; b=D+/KWHqsK26h7hHgnMiHFho3bgDJVBYtirZ9W3sJTQS5vbIawN0rwfa7VAgGFop46N wbR/5XrWm6MXQ7lkfR5KVtvrSJFZikykdizXUxmaMwFrgscoECbVn7IO+OeJNQh5DHHr WAjBp99JNgAbBDFXR3UW6RXuQdJNyP3OhqU/M46XIMohiBC1xkoIztDpW0iHEhJ3W5+S nfqUDhBjGjRisx4viFxfc1JyQWedXqdJ15ZMt6bkHNP+k5GDstpBfx6EtFTjrpcDPFUr urdU8jupLwnxDNxjE+F3mRK9Ek914/NYtj7FfjHbHnVQW28ml0qJnTMbtf4kry4fqyau kf/A== X-Gm-Message-State: AOAM531ZOqbZGmk9VZBc7Yba4q9ot3XgXc0v+l5IqGYxbs5YDQ7sN05Y p56MBOSHRq9HAqVnhLsQUXDOGA== X-Google-Smtp-Source: ABdhPJwF+bHd6KY2p1P8e9lx9oFImI5KZZLHZ+E6L7JgNPeCpkJOeRRWvVQbICk8vNLW8FvDyRKtfg== X-Received: by 2002:a17:902:6b0a:: with SMTP id o10mr761491plk.249.1597151184016; Tue, 11 Aug 2020 06:06:24 -0700 (PDT) Received: from [192.168.1.182] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id c4sm22966780pfo.163.2020.08.11.06.06.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2020 06:06:23 -0700 (PDT) Subject: Re: [PATCH 2/2] io_uring: use TWA_SIGNAL for task_work if the task isn't running To: Oleg Nesterov , Peter Zijlstra Cc: Jann Horn , io-uring , stable , Josef 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> <20200811081033.GD21797@redhat.com> From: Jens Axboe Message-ID: Date: Tue, 11 Aug 2020 07:06:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200811081033.GD21797@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On 8/11/20 2:10 AM, Oleg Nesterov wrote: > 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. Thanks, reading through this thread makes me feel better. I agree that we'll need READ_ONCE() just to shut up analyzers. I'd really like to get this done at the same time as the io_uring change. Are you open to doing the READ_ONCE() based JOBCTL_TASK_WORK addition for 5.9? Alternatively we can retain the 1/2 patch from this series and I'll open-code it in io_uring, but seems pointless as io_uring is the only user of TWA_SIGNAL in the kernel anyway. -- Jens Axboe