Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1159805iog; Mon, 13 Jun 2022 23:45:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v7C+PoHd+8WlSrwwgtfV0A8gCicNT1hw3c9LD4BJwxh/5nSfYG/p0McW+02i7iAIY4DGa/ X-Received: by 2002:a17:906:519b:b0:711:fb34:16f4 with SMTP id y27-20020a170906519b00b00711fb3416f4mr3115824ejk.275.1655189103946; Mon, 13 Jun 2022 23:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655189103; cv=none; d=google.com; s=arc-20160816; b=xHRGkN3K2T2kiujNqPTWaIKzFq18W3M8DC0me8DtqG5pWZGGBf6Uauz2av2pQ2G5Ey gEY1QPtyPcA9ZEnoZIH930J0Apbxi9zC3gqgwNhD8rw7vI82hsS1C5a68ikIf68ODF7u oNAg9Emk07bTE/TawFM+ZGCww/Z4RoNG2+6OJpQIBaMl2UJBwyNH7tUzP0lOXppzqDWG Yng1Rn+I0j967pyM8Q3o8IJ2y5TSQzLrpPEBzMAkoIs1zWjjYkRJXLAam6mrSnia/Q3C gzu/0eeUZ4S2TFgOABlmym2aqFv/ee7oTvsrmCHLdKbFYXO4ynPxvV1A4K/FLgeQMmV+ sKjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=KQn/p+WJIVQNFwoaQTH0dpkpBNJBvLUauZgDvuzZ+Bc=; b=Y/+Dvdm7IkEsA40beHhfzoDNcVMAwPdcfjdN6wLaON3NF0d2PqrERRb8AkXZUWbF0B ivSMADxMDwuQAqjBmSdzIr91YDmt1PGrCuSgPX4f/7lkwGNWwZ8srM8MmrsoqM9fZEPi waIGErllk3IQcZ/cB7f0JeO2JsjtVHaRBlL/OdJ9eLAqWYTCz7iUHUNV8rvVBdAjAqvT VyhbeG+BjywPdsllk3fAh5k7HUExHrW0n63W3slDT6UdqtlngDqLNfz+CyWjKz0tQRlF PP/58xlipgO6XTtlsHrrVQa61baFVnr1DYaEsNV4VudTnHoavn9AenfjwLDpQj8/MDTB MdVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cB6lCVOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cz4-20020a0564021ca400b0042de15f1827si9350771edb.345.2022.06.13.23.44.39; Mon, 13 Jun 2022 23:45:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cB6lCVOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238570AbiFNGgk (ORCPT + 99 others); Tue, 14 Jun 2022 02:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbiFNGgf (ORCPT ); Tue, 14 Jun 2022 02:36:35 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1CA9537BE1 for ; Mon, 13 Jun 2022 23:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655188592; 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=KQn/p+WJIVQNFwoaQTH0dpkpBNJBvLUauZgDvuzZ+Bc=; b=cB6lCVOm7QKlMKx1PbRPXpnKKohgwdOT5J/Ckq9vxNd5xJz4LjLMvBdYEJVDMhEm3qKqTi trSlms/UoipaD5blJ8l9+Gcj1ujEF8JD9oV9NjlZGESvFfUdcaqfDgQ4z70fYZd/Ew9lAU dGPlY85MKlzk6THVfG/56ZVG7dSWS80= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-520-nmntQT17OOOf6gW6NQ7IYQ-1; Tue, 14 Jun 2022 02:36:21 -0400 X-MC-Unique: nmntQT17OOOf6gW6NQ7IYQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B10E811E80; Tue, 14 Jun 2022 06:36:21 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6889FC28115; Tue, 14 Jun 2022 06:36:20 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: To: Al Viro Cc: dhowells@redhat.com, Linus Torvalds , Dan Williams , Linux Kernel Mailing List , linux-fsdevel , nvdimm@lists.linux.dev Subject: Re: [RFC][PATCH] fix short copy handling in copy_mc_pipe_to_iter() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1586152.1655188579.1@warthog.procyon.org.uk> Date: Tue, 14 Jun 2022 07:36:19 +0100 Message-ID: <1586153.1655188579@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Al Viro wrote: > What's wrong with > p_occupancy = pipe_occupancy(head, tail); > if (p_occupancy >= pipe->max_usage) > return 0; > else > return pipe->max_usage - p_occupancy; Because "pipe->max_usage - p_occupancy" can be negative. post_one_notification() is limited by pipe->ring_size, not pipe->max_usage. The idea is to allow some slack in a watch pipe for the watch_queue code to use that userspace can't. David