Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB7B0C636CC for ; Sat, 11 Feb 2023 14:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229635AbjBKONx (ORCPT ); Sat, 11 Feb 2023 09:13:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjBKONu (ORCPT ); Sat, 11 Feb 2023 09:13:50 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F7C2B2B3 for ; Sat, 11 Feb 2023 06:13:46 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id ja21so1829623plb.13 for ; Sat, 11 Feb 2023 06:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=oqGRKzSo6E4/f+woXcOCjpwjArDsyHYfDxL4HTg7iio=; b=wCNiYJcLkvEUpEZHzCL9RSSTZah20e3Vx5u3HSFTxE8bpS6ViAr7yu2nh6p7lms2yc yOAKa9NxNMFxnywW9IFuGVT0q1LbIqUR9FQgUsxxKG31pWabOZ5AxPL4nn2Eak6eBUFy z9kShKrMpIJtUnj5hM/0l2fqIh8uVfF/GjluWOL0mUT0gf0a49ylXOVttlcfR+bB7PC3 GyAHRdXjdOPP7uzT3iNyZ4YznGS5MkfCepIrwxKiMOQ+SktVrYhDDeKcrgl50xxID1bi 32NrSPKIGD0eBfPDf3QV9+Hss3B8PpPqCifUU0VKfGtwDAHQrDhNqYh5ouBiCy0xt09G ynvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oqGRKzSo6E4/f+woXcOCjpwjArDsyHYfDxL4HTg7iio=; b=rjGF81qyNzNLAK7atON8+WZvaaZS0rlz6Jz0ICkIyWTN7Qg/GA9PjSowQ9q1ixGh9M nn5QB03aCHC3t0sSJ66vCPoZxF5rN5B+sONH35csHdUuO/9GeHXJP42CPKPAnIfUQlaT AIVEHfgA9TDNmWPYA2bOpGbZfLpIjlWAU3kE8jDV3N+GCCS78HVY5DA2+rJ0TLYi0jAC x9fml2COSX297wu/JqmvtVWlM/NaE8ycXzSicqT6rrW5eweoCZJlWRlagC5Qv1gfak7r B9XH2AfkGmyxU78sHPiqe2+6it/xi6UDoB566UpjMaNOU31nDk5AkbD9dP1zAPJVDGE6 tkOQ== X-Gm-Message-State: AO0yUKX0P9+hC5a2R/0g1+lJeykVTmuZkE6pfBoJ5cQC1aQqKui28yeV geBWoIWYxkeLSDXqkqocHVwK5fkwLxaktl5P X-Google-Smtp-Source: AK7set/LnVAtiy5TUkkuzhteoCRyrs4pqpY8XSDBYd/FSNwWtCjGA99X1ZzvEOtfDL0WSzAPF6ud0g== X-Received: by 2002:a17:902:680b:b0:199:3f82:ef62 with SMTP id h11-20020a170902680b00b001993f82ef62mr15067071plk.5.1676124826228; Sat, 11 Feb 2023 06:13:46 -0800 (PST) Received: from [192.168.1.136] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id q10-20020a170902b10a00b00174f61a7d09sm5015531plr.247.2023.02.11.06.13.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Feb 2023 06:13:45 -0800 (PST) Message-ID: <55eaac9e-0d77-1fa2-df27-4d64e123177e@kernel.dk> Date: Sat, 11 Feb 2023 07:13:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: copy on write for splice() from file to pipe? Content-Language: en-US To: Ming Lei , Linus Torvalds Cc: Andy Lutomirski , Dave Chinner , Matthew Wilcox , Stefan Metzmacher , linux-fsdevel , Linux API Mailing List , io-uring , "linux-kernel@vger.kernel.org" , Al Viro , Samba Technical References: <1dd85095-c18c-ed3e-38b7-02f4d13d9bd6@kernel.dk> <7a2e5b7f-c213-09ff-ef35-d6c2967b31a7@kernel.dk> <2bb12591-9d24-6b26-178f-05e939bf3251@kernel.dk> From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/10/23 8:18?PM, Ming Lei wrote: > On Fri, Feb 10, 2023 at 02:08:35PM -0800, Linus Torvalds wrote: >> On Fri, Feb 10, 2023 at 1:51 PM Jens Axboe wrote: >>> >>> Speaking of splice/io_uring, Ming posted this today: >>> >>> https://lore.kernel.org/io-uring/20230210153212.733006-1-ming.lei@redhat.com/ >> >> Ugh. Some of that is really ugly. Both 'ignore_sig' and >> 'ack_page_consuming' just look wrong. Pure random special cases. >> >> And that 'ignore_sig' is particularly ugly, since the only thing that >> sets it also sets SPLICE_F_NONBLOCK. >> >> And the *only* thing that actually then checks that field is >> 'splice_from_pipe_next()', where there are exactly two >> signal_pending() checks that it adds to, and >> >> (a) the first one is to protect from endless loops >> >> (b) the second one is irrelevant when SPLICE_F_NONBLOCK is set >> >> So honestly, just NAK on that series. >> >> I think that instead of 'ignore_sig' (which shouldn't exist), that >> first 'signal_pending()' check in splice_from_pipe_next() should just >> be changed into a 'fatal_signal_pending()'. > > Good point, here the signal is often from task_work_add() called by > io_uring. Usually you'd use task_sigpending() to distinguis the two, but fatal_signal_pending() as Linus suggests would also work. The only concern here is that since you'll be potentially blocking on waiting for the pipe to be readable - if task does indeed have task_work pending and that very task_work is the one that will ensure that the pipe is now readable, then you're waiting condition will never be satisfied. -- Jens Axboe