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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18728C433F5 for ; Thu, 6 Jan 2022 22:05:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD2456B0073; Thu, 6 Jan 2022 17:05:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A81D36B0074; Thu, 6 Jan 2022 17:05:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 922116B0075; Thu, 6 Jan 2022 17:05:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 83DC76B0073 for ; Thu, 6 Jan 2022 17:05:49 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3A66595AE8 for ; Thu, 6 Jan 2022 22:05:49 +0000 (UTC) X-FDA: 79001245218.20.F9D669B Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf28.hostedemail.com (Postfix) with ESMTP id D881DC000F for ; Thu, 6 Jan 2022 22:05:48 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id rj2-20020a17090b3e8200b001b1944bad25so4580486pjb.5 for ; Thu, 06 Jan 2022 14:05:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g2O7xnrLPpqXXwOCapU3Xp7r0vQceHZ0G5UiRjpq8YU=; b=T5y8RqSbxZC8esbKQZXw4JqYsM/uqWOXxZ7+KJmj6LC1SPZCOyFwLoe7oEEQ7c6RYK nIJRb6O6w+g3z+0NSdHRkUiLoBlvNlN7J8gWt4t6KQNCtnKIzQfvYSnyx0jB0h4gP7eY tSMsnQD8PDUyExKJvp/uYW/0IW6DLVZPDYcpz/KVWAcNBzMaB4U+dd9TA5HYVLIC1+vP XkGC2IQnIAEg5MRd6fuhFGpWRjiT7066ciz0sX39wqVV7U6AEAD6bYwcuyTnoqRscyiI BfN/zDC30gUAqEDmfvtG0zh/V9axSPRv4CokOCyAfAV8a7+fQIAuD4UWdx/eUJet4bgD rCRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=g2O7xnrLPpqXXwOCapU3Xp7r0vQceHZ0G5UiRjpq8YU=; b=DunFPIX3W95/m5uFJ6fCJkYtYbnCKUeprnl2UlPf3eaaRlSI8SQ4c6dyL6aijb/11/ BLju/tnrn+RHABfE/hgwN+bcTAp2hEerj76+TPGKJmZCqidSRTYCSzvvGB+dod0N+JGn 99oLE7eSwKcUVbUwQOMk6fZdQxMaeHKXuC0Hm3cSpbXDVo1NO/ZRDkZKgYYMmBvNXE6a lq/wZ4z017zQ7UB0npTUq/qKPQu4wvUORO+VPw7JX7/c1pyRR6DKQmKu/LAxAixeiOjM kI1YZTRLtGm5kIHkiPG3KWuwMusYW+pAlji56fi7Ldgp6qHg2NlzJOf9wDrH1UU9qULI xi9A== X-Gm-Message-State: AOAM532J+vUERSwhwVg06cktIeftXZouPP5tRpr2FTYDm+RclijIaB34 C03sIir85q0MSQhVbbFHI/E= X-Google-Smtp-Source: ABdhPJzxXkAt0X3wMEjyDjnGygiMMan8y3eiebKhXSdK7HpNq+PQfq27Y1el0Y2io4yaCknV2yFQwg== X-Received: by 2002:a17:90a:8983:: with SMTP id v3mr5723579pjn.11.1641506747772; Thu, 06 Jan 2022 14:05:47 -0800 (PST) Received: from localhost (2603-800c-1a02-1bae-e24f-43ff-fee6-449f.res6.spectrum.com. [2603:800c:1a02:1bae:e24f:43ff:fee6:449f]) by smtp.gmail.com with ESMTPSA id h7sm3598689pfc.152.2022.01.06.14.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 14:05:46 -0800 (PST) Date: Thu, 6 Jan 2022 12:05:45 -1000 From: Tejun Heo To: Linus Torvalds Cc: Eric Biggers , Zefan Li , Johannes Weiner , Peter Zijlstra , Juri Lelli , Vincent Guittot , Ingo Molnar , Hillf Danton , syzbot , linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Linux-MM Subject: Re: psi_trigger_poll() is completely broken Message-ID: References: <000000000000e8f8f505d0e479a5@google.com> <20211211015620.1793-1-hdanton@sina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: D881DC000F X-Stat-Signature: 458gz7qf3f7xt86o4dz93oq4g9w7jmx8 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=T5y8RqSb; spf=pass (imf28.hostedemail.com: domain of htejun@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=htejun@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspamd-Server: rspam10 X-HE-Tag: 1641506748-318281 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Happy new year, On Wed, Jan 05, 2022 at 11:13:30AM -0800, Linus Torvalds wrote: > On Wed, Jan 5, 2022 at 11:07 AM Linus Torvalds > wrote: > > > > Whoever came up with that stupid "replace existing trigger with a > > write()" model should feel bad. It's garbage, and it's actively buggy > > in multiple ways. > > What are the users? Can we make the rule for -EBUSY simply be that you > can _install_ a trigger, but you can't replace an existing one (except > with NULL, when you close it). I don't have enough context here and Johannes seems offline today. Let's wait for him to chime in. > That would fix the poll() lifetime issue, and would make the > psi_trigger_replace() races fairly easy to fix - just use > > if (cmpxchg(trigger_ptr, NULL, new) != NULL) { > ... free 'new', return -EBUSY .. > > to install the new one, instead of > > rcu_assign_pointer(*trigger_ptr, new); > > or something like that. No locking necessary. > > But I assume people actually end up re-writing triggers, because > people are perverse and have taken advantage of this completely broken > API. IIRC, the rationale for the shared trigger at the time was around the complexities of preventing it from devolving into O(N) trigger checks on every pressure update. If the overriding behavior is something that can be changed, I'd prefer going for per-opener triggers even if that involves adding complexities (maybe a rbtree w/ prev/next links for faster sweeps?). Thanks. -- tejun