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 3DF52C433EF for ; Tue, 11 Jan 2022 03:02:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A8236B0072; Mon, 10 Jan 2022 22:02:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 455FF6B0073; Mon, 10 Jan 2022 22:02:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31D7B6B0074; Mon, 10 Jan 2022 22:02:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 234956B0072 for ; Mon, 10 Jan 2022 22:02:14 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D723E181BC81D for ; Tue, 11 Jan 2022 03:02:13 +0000 (UTC) X-FDA: 79016507346.02.41AA03E Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) by imf23.hostedemail.com (Postfix) with ESMTP id 870FA14000E for ; Tue, 11 Jan 2022 03:02:13 +0000 (UTC) Received: by mail-yb1-f173.google.com with SMTP id d7so10563913ybo.5 for ; Mon, 10 Jan 2022 19:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UsWqKCbZLBuzi7usjCmtz/JjjGQctwwjiuVxBcWGtdk=; b=COAmUaQw1ztu/k34hHssrqxJ5Ru3MzmDhsKdPPt76mfpNYxw3av7/WBjz3CxjQpK0P c8WaHCZoGcMflm4zxQj3xt3AExLTuuwAVwPzhm4wAGd4WDQZaMoE+QsfRvxHm/xC30MC tMQdBzZ94m+7iRWM+StA7HvVqsD/xsw5/b+Moc0mT/nllajjOGKBVi/v+hNlKHcklW6l 4rwBvGjPvnV8z4NjMehPSrJzkRalwtqGA/k/j1xwnSe+wOWIL96dXFP1QRAkn4Jr7Pfl 0v/kHVgCFYj7OTUm+rO3SJ3JCOqgZPJPd2yy+Nr9ldppnJPpYqNXQGP2oCANCXR6J6gc fyoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UsWqKCbZLBuzi7usjCmtz/JjjGQctwwjiuVxBcWGtdk=; b=y9BasFv8kfGSrCywiYIFWr7GK5DrfcfFTBKJMBaPx8wcXhlvm7By8T5LSjiQ9LQxF1 ihR6PToqJWNAJLamkgWlm2hqrNTeVRD8QzlcfJL1wtiSAVhXwS3b3D3a4uHlLzfM3xma 2oaexxgbwetpjxu3EHuYH3WGdG9XpOJySksL6XCg87/9XEer/26yVN5IPiuEg24tpDKN +0sef2zczQ/Ku2mSF4VT+7iLLQ6CS5+1zpamHTb+f0Dz+tCoVpcRgJzKk+aytoOD/iXQ sE5TJRjc1gYzuGOWNLctg8LO6uWtDef+OHVwp1cPefvBMgMbGRO9//k/uRyAFBatdAIb vhoQ== X-Gm-Message-State: AOAM5329pVmoS47qrnXh625TZCw6uzQVNKthTbQB2x1r+RriHvJmAHox OfKVsnzWxtWZW2mA3pDvT2KlG5GevT4Xr/pU93bHuQ== X-Google-Smtp-Source: ABdhPJzDqMdEbnslQ3eNG6BEi4iBJgsxYWS/6DXV0gipP6o4EahWyajWmuxQEoDLns7m53UXcNmtAhCtWktzOBb64gk= X-Received: by 2002:a25:6942:: with SMTP id e63mr3568929ybc.602.1641870132644; Mon, 10 Jan 2022 19:02:12 -0800 (PST) MIME-Version: 1.0 References: <000000000000e8f8f505d0e479a5@google.com> <20211211015620.1793-1-hdanton@sina.com> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 10 Jan 2022 19:02:01 -0800 Message-ID: Subject: Re: psi_trigger_poll() is completely broken To: Linus Torvalds Cc: Johannes Weiner , Eric Biggers , Tejun Heo , Zefan Li , Peter Zijlstra , Juri Lelli , Vincent Guittot , Ingo Molnar , Hillf Danton , syzbot , linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 870FA14000E X-Stat-Signature: kxdftf5eu56kexjrioqzknxwezxsrbt1 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=COAmUaQw; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of surenb@google.com designates 209.85.219.173 as permitted sender) smtp.mailfrom=surenb@google.com X-Rspamd-Server: rspam03 X-HE-Tag: 1641870133-185240 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: On Mon, Jan 10, 2022 at 10:19 AM Suren Baghdasaryan wrote: > > On Mon, Jan 10, 2022 at 9:42 AM Linus Torvalds > wrote: > > > > On Mon, Jan 10, 2022 at 9:25 AM Suren Baghdasaryan wrote: > > > > > > About the issue of serializing concurrent writes for > > > cgroup_pressure_write() similar to how psi_write() does. Doesn't > > > of->mutex inside kernfs_fop_write_iter() serialize the writes to the > > > same file? > > > > Ahh, yes, it looks like that does solve the serialization issue. > > Sorry, I missed that because I'm not actually all that familiar with > > the kernfs 'of' code. > > > > So the only issue is the trigger lifetime one, and if a single trigger > > is sufficient and returning -EBUSY for trying to replace an existing > > one is good, then I think that's the proper fix. > > > > I'm very busy with the merge window (and some upcoming travel and > > family events), so I'm hoping somebody will write and test such a > > patch. Please? > > Yes, definitely. I'm on it. Will try posting it later today or > tomorrow morning if testing reveals something unexpected. My first attempt to fix this issue is posted at: https://lore.kernel.org/all/20220111025138.1071848-1-surenb@google.com/ Couple notes: - I don't think we need psi_trigger::refcount anymore, therefore it's removed. - synchronize_rcu is kept to ensure we do not free group->poll_task while psi_schedule_poll_work is using it. - Documentation needed minimal changes because it did not clearly specify how trigger overwrite should work. Now it does. I ran as many test cases as I could find/create. I'll work on adding some kselftests for psi triggers to test different usage patterns. Thanks, Suren. > Thanks! > > > > > Linus