Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5333783ybv; Tue, 11 Feb 2020 13:43:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwH9pRC6Bum2ZOMK9Wthr6VacJ9e9OBRP7DXSF/CTTrg27WNkiN3xH2CekEGVJumghPgMDq X-Received: by 2002:aca:f517:: with SMTP id t23mr4037960oih.160.1581457405947; Tue, 11 Feb 2020 13:43:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581457405; cv=none; d=google.com; s=arc-20160816; b=hgB2kziTcdZfMa4NNolQHNFMoUmAiTebPqPeo/fpf0MJcKjKlIvLmko+sXGfK5hqit na/SNdwIVMx+jG2KYwN0jnUQbSpiL2tDfAiM9tpd0bR2O7u9LXqNba9eDpzUAk/JEnRq DZ5NleglRy2eAzXjdMPfKBfZ1liLGhCtC41xYm+hZVNx8eWV2yI2h07zez5r0kqZz2bg fkuCet0wPgFz9hwUSKC76ajs5soWgENrFUdzhG3aFyX5kwCKAesFgZfejk7bJpf2LKvO JN7PAaI3efzO/hCAMBxH4gNgbJ3+LE7oogOHI1UxKeAt7PIfmVjA8gL8s92QU+Ltjd8s R+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=aBmOqLH1PZiFTOFcGqDZh0Dx5zViJtKjdR8Za6YFAus=; b=MuKUCGxZddqouq8UKSkP4yHA0uxi/lp2cJrIt9mYxhmld+H7R90h/W6M+tLqRStBWB w4Us7GFhFTjTLXONq8l3flijoPJquh3A/XoGoU3jrYBAjQDouzluEjDOjRVgOkCYfDko Hn9rXVepazb79IDoBOVhoKE2kLt+LQpn3O+I+n73HxefGnFBP100aQypHlM0qHHjcMWH 4/nN57kMe/5oPFh6TFfhykhQ7i9wjdKh/6Vz5rn8OThOTzsS5iJeHxPpDXVMFgDmBo1V +ezu3JKP+OuurxnsS5ZoNi7aL5oyV+mMwK2Z6ELa0hpTqZFd/E+KAtVeeu+3Sv1i7IM/ U1/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=RZXwnuei; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 13si2286450oiy.28.2020.02.11.13.43.14; Tue, 11 Feb 2020 13:43:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=RZXwnuei; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729157AbgBKU70 (ORCPT + 99 others); Tue, 11 Feb 2020 15:59:26 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:42117 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728624AbgBKU7Z (ORCPT ); Tue, 11 Feb 2020 15:59:25 -0500 Received: by mail-io1-f68.google.com with SMTP id s6so13396135iol.9 for ; Tue, 11 Feb 2020 12:59:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=aBmOqLH1PZiFTOFcGqDZh0Dx5zViJtKjdR8Za6YFAus=; b=RZXwnueiFOQ2Vf+tKDg+B+Uev1it96O0IUJDh9R1bQyR0+ak9Dssh/ddGPvF5lVm3q nmiC1cXE16tJgM3RfZx9lxRF9ZxbRbpq27hm9Il2WxLH2EBSYMZsKZ4F2rHEk1uefYDB mtt5lUNt9nue5gZBaRxGw1FV2a8RaIHeZ06UrLAlgvpOq2R4kRHT8JA0OS4BLetuFuR8 JSvJtqbpDT7awWyh/HxqOuwCgrBwF6t+/qB3/OlOSiJkcpGJgtdOutFZlVAvPZZVP5eg kH3Ursuv1/G2DwDFNlDZwCtreOx4DaGPQQOm1mb0zDd3yseu5feQAoZPNz56+dMhTO7/ UJDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aBmOqLH1PZiFTOFcGqDZh0Dx5zViJtKjdR8Za6YFAus=; b=QFB+61NR74N57FzdUEm9riHns9RShnLZCB87lQdX1cuQjkal59TVME53859Pj/ZI7f cUVMydK0HlozpD3EerFuuoS+0VJf+Yoj/Glxw2gQmpdr1s15nrj0msFK4A4xfClQGZ6p sm0ffWPCT/b4UndwpaFmtHlq/U4UEFp26lYbeHOHpakEnocEZLoWkzzXu2xhn7UDKIcL OvSm9V07EM7vDs311g8H3pVbGmxID3gsaGll6JI4vc28q/iyR81bKimsX4zQyzmhbJFm LkDGeQSeu6K0Bzfx6/4hW81Xlwgx/EBt439RSwVoyaXcCwZlN64VBH9aKsq8ml+x9L4r pVDA== X-Gm-Message-State: APjAAAVHvXFmPjbKRS0p8egkD1TSriHupftiOes6j7D0uMTdAXkUSO1o xZnDjRE1P4aj5TX+NWzUYqTEPqa3gR0= X-Received: by 2002:a05:6638:81:: with SMTP id v1mr16179966jao.143.1581454764728; Tue, 11 Feb 2020 12:59:24 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id h6sm1308495iom.43.2020.02.11.12.59.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Feb 2020 12:59:24 -0800 (PST) Subject: Re: [PATCH 3/5] io_uring: fix reassigning work.task_pid from io-wq To: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <728f583e7835cf0c74b8dc8fbeddb58970f477a5.1581450491.git.asml.silence@gmail.com> <4a08cc5a-2100-3a31-becb-c16592905c86@kernel.dk> From: Jens Axboe Message-ID: <82bef6dc-608e-6fde-44fb-58ee517d234d@kernel.dk> Date: Tue, 11 Feb 2020 13:59:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/11/20 1:57 PM, Pavel Begunkov wrote: > On 11/02/2020 23:21, Jens Axboe wrote: >> On 2/11/20 1:01 PM, Pavel Begunkov wrote: >>> If a request got into io-wq context, io_prep_async_work() has already >>> been called. Most of the stuff there is idempotent with an exception >>> that it'll set work.task_pid to task_pid_vnr() of an io_wq worker thread >>> >>> Do only what's needed, that's io_prep_linked_timeout() and setting >>> IO_WQ_WORK_UNBOUND. >> >> Rest of the series aside, I'm going to fix-up the pid addition to >> only set if it's zero like the others. > > IMO, io_req_work_grab_env() should never be called from io-wq. It'd do nothing > good but open space for subtle bugs. And if that's enforced (as done in this > patch), it's safe to set @pid multiple times. I agree, it'd be an issue if we ever did the first iteration through the worker. And it'd be nice to make the flow self explanatory in that regard. > Probably, it worth to add the check just to not go through task_pid_vnr() > several times. Good point, that is worth it on its own. -- Jens Axboe