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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 328CAC433EF for ; Tue, 11 Jan 2022 03:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235587AbiAKDCd (ORCPT ); Mon, 10 Jan 2022 22:02:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235690AbiAKDCN (ORCPT ); Mon, 10 Jan 2022 22:02:13 -0500 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95725C06173F for ; Mon, 10 Jan 2022 19:02:13 -0800 (PST) Received: by mail-yb1-xb2b.google.com with SMTP id c6so41472879ybk.3 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=WxRgDqw39rpPgaotWA2rYAxVGuMzhTmjFfLFFYCHb2g2BLPDhLRxpfHO3CPRDTNKtJ 6n4fYmiCqdvLL3fvZtuOan2Wf9PRCwhkF9wBkUrgpnYQ3v185BMfTx0fusagQ7f9xyFy moezcw//uGNQZKO2xbaFGm6DwRRiMmoLEQNOkKk56qck3I+7azbQ6mkI8mUNkebCwfFh iOKrA+sY05uIHuoHJTOKizQeSSefgm38PxXAmUm+4/g4SUoCWU5Epr81JXGXq+5lh0/G mHj5yxFIQR2ZBLxiqBv/mpTftY8Px/LSpLVtU7T/qq5HFi2pH5BHSvpZTp9kI+tU0jg9 7GzQ== X-Gm-Message-State: AOAM533aijI6B2jv+fiGlUpjomkAMn6Qf+5Emp/l0oSSEapRaMrXivuD vt8SjaOPOQEXkmbZ4ZlqZp6JKCxikhG9fYoopQA0NA== 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" Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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