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 X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56331C2B9F4 for ; Tue, 22 Jun 2021 15:50:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21C0860233 for ; Tue, 22 Jun 2021 15:50:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21C0860233 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pIIWJKS/EwgFREkj17ay4t6/4wA1EQNfm4rP4NQHOV8=; b=vkBR+fSk36DgfW sFpmNeL69F3WkrNfRjZJdw/gzp/KlHGxAJZjWZYVDPk31PI6D+5GzEk1+x6i5r1LSEaJSWZDwxb9w 5SCgZ22OAnM3gasaw0N78nKrPAyx1qgHDIGAL+xpgGzaSRC12/fd++L3nh1FYl+IW2iYiLJBO2u/s wUDX09vOOL/arhxGJ3oNxewH5sUAc1iTseZYTkQn5cCi3kBK7Fc2YLIG4J5kp/bklWDKChC2gSUjV dl3rYamYN+KlqB8zOg9uHVDCrD2t7B9UIcH8O4Rta1+0ZNo5jx8T2ydywRh37Qad1LXLyOy6zPjlC K6JSd9duBExrpjYSxfeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvieC-007mtl-Ux; Tue, 22 Jun 2021 15:49:09 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvie8-007msc-Qd for linux-arm-kernel@lists.infradead.org; Tue, 22 Jun 2021 15:49:06 +0000 Received: by mail-qk1-x732.google.com with SMTP id c138so40697016qkg.5 for ; Tue, 22 Jun 2021 08:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=D08i5WTXo1+ei91JvYVmebG92e88A+VfKzRMQAIzqTM=; b=jgidxwU3rvWrgcqGkIz7gxsf8q34Aei30cqet0yNDoKa6Hm/JCxj6yqJiLESLRrZVA ll899Zhw7iQb7AeReITNvPVIMJ4IFUuR9kw/41EtBa1H0NaYNkvUG59sER6B7M/8D37g YyVOTgTwTFB2xwsVR4l7lukpfDyToapK0CRGmIhcJFHIp0F/AnvtyqJPTOzu7/ae/Tae x06TzLOotgnMYXO25mEI0JSnrFdG9v6SjquOLDWjprM/RezT7h0/pq7eKzpXLL4XgN1I lvf8ANIDlauF1WKmS9U29MZxvstcp1bvqEw/ILDfXRe9l4N0RVyjBJDDwLa4aq2UoIfx K56A== 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=D08i5WTXo1+ei91JvYVmebG92e88A+VfKzRMQAIzqTM=; b=HSWU6UeVeP2xpP6zfSalTeRJgOtt0t73hVWvkwlKsazzQkYm7eOrkgOwQFFI6VJ/Vu sBl8JWUnUF/qP6rAwWQIl4+UJfdJeCDnjq+o+bpPoZcpuELW/mXLG7YIKJ6Oueo+gLl6 8Zv8gc5KvsqmD8nQf9p6roUFU2AN24owSvBRXRGnOTcBuHKS6bae5r13n5WnvPiE474V o5cOkgQeEd8T6Gjjn7jc1W/CGvHzDxXT/7WVkwVtsV5b0E16dj2A2ysj2qev/yONF+aj TnUDNoQmd7IA0XAlG2SnkuEuIhLpoKMPdcIWoxM0Swlp9UCAfRW72WQ/w1xCqgFjmAtf l3Yg== X-Gm-Message-State: AOAM530BgwU78TcBNPb77msgsvHlW0Jx1HB60n5/DtxdsB8ncnzE7nac Q4XuVmL6cVSo8QmIU3+5fm4m1tga/OGI+JIh/95Pzg== X-Google-Smtp-Source: ABdhPJxlSgAQuZC1mdGJER44LnEsZkvBvVA3DgjtrCOiG9SBqYE3gDoWVFuBtbTyWDOaaDGD0gFFHk3axXToVC3sQME= X-Received: by 2002:a25:d913:: with SMTP id q19mr5873657ybg.397.1624376943574; Tue, 22 Jun 2021 08:49:03 -0700 (PDT) MIME-Version: 1.0 References: <20210617212654.1529125-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 22 Jun 2021 08:48:52 -0700 Message-ID: Subject: Re: [PATCH 1/1] psi: stop relying on timer_pending for poll_work rescheduling To: Johannes Weiner Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall , Mel Gorman , Daniel Bristot de Oliveira , matthias.bgg@gmail.com, Minchan Kim , Tim Murray , YT Chang , =?UTF-8?B?V2VuanUgWHUgKOiuuOaWh+S4vik=?= , =?UTF-8?B?Sm9uYXRoYW4gSk1DaGVuICjpmbPlrrbmmI4p?= , LKML , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel-team X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_084904_922398_D9B85E99 X-CRM114-Status: GOOD ( 28.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 22, 2021 at 8:08 AM Johannes Weiner wrote: > > On Tue, Jun 22, 2021 at 03:56:03PM +0200, Peter Zijlstra wrote: > > On Thu, Jun 17, 2021 at 02:26:54PM -0700, Suren Baghdasaryan wrote: > > > Fixes: 461daba06bdc ("psi: eliminate kthread_worker from psi trigger scheduling mechanism") > > > Reported-by: Kathleen Chang > > > Reported-by: Wenju Xu > > > Reported-by: Jonathan Chen > > > Signed-off-by: Suren Baghdasaryan > > > > Johannes? > > Looks generally good to me, I'd just want to get to the bottom of the > memory ordering before acking... > > > > -/* Schedule polling if it's not already scheduled. */ > > > -static void psi_schedule_poll_work(struct psi_group *group, unsigned long delay) > > > +/* Schedule polling if it's not already scheduled or forced. */ > > > +static void psi_schedule_poll_work(struct psi_group *group, unsigned long delay, > > > + bool force) > > > { > > > struct task_struct *task; > > > > > > - /* > > > - * Do not reschedule if already scheduled. > > > - * Possible race with a timer scheduled after this check but before > > > - * mod_timer below can be tolerated because group->polling_next_update > > > - * will keep updates on schedule. > > > - */ > > > - if (timer_pending(&group->poll_timer)) > > > + /* cmpxchg should be called even when !force to set poll_scheduled */ > > > + if (atomic_cmpxchg(&group->poll_scheduled, 0, 1) != 0 && !force) Will change to Peter's suggested "if (atomic_cmpxchg(&group->poll_scheduled, 0, 1) && !force)" once the ordering question is finalized. > > > > Do you care about memory ordering here? Afaict the whole thing is > > supposed to be ordered by ->trigger_lock, so you don't. > > It's not always held when we get here. > > The worker holds it when it reschedules itself, to serialize against > userspace destroying the trigger itself. But the scheduler doesn't > hold it when it kicks the worker on an actionable task change. > > That said, I think the ordering we care about there is that when the > scheduler side sees the worker still queued, the worker must see the > scheduler's updates to the percpu states and process them correctly. > But that should be ensured already by the ordering implied by the > seqcount sections around both the writer and the reader side. Thanks Johannes! I have nothing to add here really. > > Is there another possible race that I'm missing? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel