Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2936284pxb; Tue, 24 Aug 2021 10:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgVVmCHiZ7ALCXu7JLIVe57t+Wtl+BNzWznjP9+DthpdXWyvEW1DVpqdeJ1JgqOmQgsiRr X-Received: by 2002:a5e:c609:: with SMTP id f9mr31047822iok.127.1629827900675; Tue, 24 Aug 2021 10:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629827900; cv=none; d=google.com; s=arc-20160816; b=gVgIrnM+yQ8e4MioY4+SdiqrAw6AJR/QxpIF5xRFB9F1Fwlu+HtNAYNgF2k26Pp4Kv 0JOYhKWJWkQ8U5Ls0R67iCtkEFfvsIvK4qNkVU2E0S3I/jNnUshcFJjjngjbShRAhotz cBQQzAkcV1JRcJVEk+haLt3WnG5TkVlHeKToazF4mCN6IGkse4wObz5cBhorPbISD68e qjviVitG8/Ig2vnL8YHJ//Mr2vRgFVPdO7tb8rlbnt6LEWYWoHsjDQAujYs3ZDqv5RT+ HbZBXmGNlEDIzO1HHTpyi3TPQAFtqxVFCcjbJeqcc1vZVAtBnUt6mYmjRWKH89sTu4lx mYOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jmXJ+V7lZIXD6SyN6KE+2U5NQ7rogw+ZoqgEH0zDtHg=; b=deVZF2qwXdTjYVjtXhD+zHbFx4oOwc3opx9gS8VMAK0j2uZ8MlTugarOxpq0kQL3fl YfzzZAU4vJAKpcn1CyyWcFmZ7Ab6dNJCH0VNW9lg6Xg8SqzF2Ik6QxVQyjmsq+3c8q+a xPxEaB26A25/y6hcM4uxn+41fga3wgN7h3MKuFx+MfRHwO0H9qPCEohbuDdLKpSRGJrl uT40ykJ1P66WxvuEM3SX99LF6wmhMAK1f/2ILk1s/a6YUihkMR1RjAVlXrw+987iD8ne 2FiVGyRxtY3bMXw0mCcx7/c5ArHqJxnsrybHkFTZN5TxLYctHdyjNFQ+u476rvCiuSSp Bk6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=MSmwOXkc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c18si13752914ioz.59.2021.08.24.10.58.08; Tue, 24 Aug 2021 10:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=MSmwOXkc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238972AbhHXR6M (ORCPT + 99 others); Tue, 24 Aug 2021 13:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239633AbhHXR6C (ORCPT ); Tue, 24 Aug 2021 13:58:02 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3DB7C02B934 for ; Tue, 24 Aug 2021 10:32:51 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id c12so39021074ljr.5 for ; Tue, 24 Aug 2021 10:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jmXJ+V7lZIXD6SyN6KE+2U5NQ7rogw+ZoqgEH0zDtHg=; b=MSmwOXkc+Kc3oeb1McdIefPnaSKK1tUjlY0nkZD7L/kbV2OR3rA5B4zvU62rrCFPTD imur3mL+r5KHuPzVbrBsO+//rzm6CwbgJK53azH5PJl+slbA8nwKICyykpOyQb1+8dCQ EqaMLkFB8MY1USjCUwTQvzsabgoyeTWFYfqg0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jmXJ+V7lZIXD6SyN6KE+2U5NQ7rogw+ZoqgEH0zDtHg=; b=KEJHLXgCEORcjsNDDFEk0bYW5GFLL3DYvIlW732sx3/dRrA56+e3YbNIU6grNwyoad oMIXREQ4TlbC717CjnQWDXUQILbzWnULcHW3QbCIw6lxUjZoR/zLRqBUFEVP1c29m+Qd mMDIVnvImOkf8wDbgHpLCPJGxu0apA6Q8UPTLRAQmoM2T9fQVJ9Y9lhwANgqwxuUAcMn YS/TO8tBmBzIVAL48gvpmIjTnMdNCMvcAWxBpHoHq8iKNNQMOhjgzlfQAePOc70cikCZ ysLlVNGn3WwRE57hNiIjCSSphkzklW6ScqhMqMlMg5MlbzZ8Ag+vqgcC29mrmfSOzj6h yElw== X-Gm-Message-State: AOAM532O9Faf2M6XE6/SxSYglj6q3220GH14x97/6mFXjVT54MD0qgd3 dAHFtMUMKCpOwo4rMlG+CJs9PjRwLqev3F4U X-Received: by 2002:a2e:9455:: with SMTP id o21mr33031569ljh.103.1629826370062; Tue, 24 Aug 2021 10:32:50 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id e19sm1847539ljj.28.2021.08.24.10.32.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Aug 2021 10:32:49 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id g13so47070457lfj.12 for ; Tue, 24 Aug 2021 10:32:48 -0700 (PDT) X-Received: by 2002:a05:6512:2091:: with SMTP id t17mr29808872lfr.253.1629826368002; Tue, 24 Aug 2021 10:32:48 -0700 (PDT) MIME-Version: 1.0 References: <20210824151337.GC27667@xsang-OptiPlex-9020> In-Reply-To: From: Linus Torvalds Date: Tue, 24 Aug 2021 10:32:32 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [pipe] 3b844826b6: stress-ng.sigio.ops_per_sec -99.3% regression To: kernel test robot , Colin Ian King Cc: Sandeep Patil , Mel Gorman , LKML , lkp@lists.01.org, kernel test robot , "Huang, Ying" , Feng Tang , Zhengjun Xing Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Added Colin King, as this looks to be related to stress-sigio.c ] On Tue, Aug 24, 2021 at 9:22 AM Linus Torvalds wrote: > > On Tue, Aug 24, 2021 at 7:56 AM kernel test robot wrote: > > > > FYI, we noticed a -99.3% regression of stress-ng.sigio.ops_per_sec due to commit: > > Well, that's bad. > > > commit: 3b844826b6c6 ("pipe: avoid unnecessary EPOLLET wakeups under normal loads") > > You fix one benchmark, you break another.. > > What's a bit odd is that this commit basically reverts commit > 3a34b13a88ca ("pipe: make pipe writes always wake up readers") which > did *not* result in any kernel test robot report. Hmm. I have a possible clue. I suspect this may be timing-related, and I wonder if the kernel test robot just didn't happen to notice - or report - the other edge of this performance regression because it ends up being random enough. In particular, I think stress-sigio.c is subtly buggy, and the "send SIGIO on every write" may have effectively hidden the bug. Here's my theory on what's going on, and why it has tghat odd -99.3% regression: - the child in stress-sigio.c does multiple writes in quick succession, while the parent is scheduled away - the pipe was empty at the beginning, but we send just *one* SIGIO for all these writes - the parent gets the SIGIO, and goes to stress_sigio_handler(), and reads the buffer but the parent doesn't necessarily *empty* the buffer, so it won't get any more SIGIO signals from subsequent writes. The reason this is timing-dependent and about luck is because the *read* size is BUFFER_SIZE (4kB), but the write sizes are BUFFER_SIZE >> 4 (256 bytes), so 99% of the time if the parent is at all timely, it will do that big read and empty the buffer. But if the child ends up able to do more than 16 writes in a row before the parent wakes up and reads data, the buffer will have more than 4kB of data in it, and when the parent SIGIO handler happens it won't empty the data, and so it will never see another SIGIO. And again - I think this all happened before too (ie before commit 3a34b13a88ca) and so 3b844826b6c6 ("pipe: avoid unnecessary EPOLLET wakeups under normal loads") isn't a _new_ regression, it just exposed the bug in the test-case again, and this time the kernel test robot caught it. In other words, I think this is very similar to the EPOLLET problem: user space expected (perhaps not _intentionally_) that SIGIO would happen over and over again when you add new data, even if the pipe already had data. So then commit 1b6b26ae7053 ("pipe: fix and clarify pipe write wakeup logic") came around back in 2019, and only sent SIGIO when the pipe buffer status _changed_ (ie went from empty to having data, rather than "there's new data") and at that point stress-sigio.c became very fragile. We could do the same ugly thing for FASYNC that we do for EPOLLET - make it always fasync on new data, exactly because the previous SIGIO might not have emptied the buffer completely. I'm a _bit_ surprised that the kernel test robot didn't catch this back in 2019, and also didn't report this when commit 3a34b13a88ca ("pipe: make pipe writes always wake up readers") should have sped things up again, but I guess the "it's very timing-dependent" might explain it. Colin, comments? Anyway, the above blathering is not based on any actual real data. I'm just looking at stress-sigio.c to see what could be going wrong, and what would explain the test robot report. It's the only thing I see, but maybe somebody else sees anything else.. Linus