Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp239628lqt; Thu, 18 Apr 2024 13:40:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCs3008BN7hl1c9/TQVc+ipZ09diYg5hV+SHDsB5DkKGaHDY/cfnRpbYPgGXD3Vw7isYuSObhWmFygpIasAmmFX4TEgeYZel9sgZEzSg== X-Google-Smtp-Source: AGHT+IGDrLPP8trMeW+r0hsomxJA/Aohzijs775ovoXDm7jBTEkVYmeJ/k701Zerw3ZGOeYgC/qU X-Received: by 2002:a17:906:bc5a:b0:a55:73c3:f820 with SMTP id s26-20020a170906bc5a00b00a5573c3f820mr102668ejv.50.1713472834215; Thu, 18 Apr 2024 13:40:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713472834; cv=pass; d=google.com; s=arc-20160816; b=xjNqoHe+HXX8iU3molSqS7rH0nKlZfPm9J/Fq1d2eFJfuiSTt5rmWldsd/y5H711Tw fOvBOAPLlXxOKup3wvr+lgD1zMFoOyvZ16Km+6Lxz6AEJP5yPXoRYSXveARdJivRs/x9 OcG5zOnGiMhb2eh3M4vBD+umE95cWKNDaRPuZbM0lkElUoqbX+sOzoJj1SDKvbFd3tZm 9FhZ1wZOlXVRhjxxwhzywW0HSABknavj3UKAV2dK0jZF9ZUrApyN9vgCD39wAJorsVMO FljRWMEh4XFtORynoNK6GAYqQ0y6ToZTYUe3YuZGhRx3n6s5M+gQ/D9hziipuCPY05AQ AvtQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=djyBKRlGRpWDdeJHGkQSaOnuWsBmFhDAvHccO4EOJ1k=; fh=Sq9pGy0En7pTEjFcJZZJQEbDU18FmnzGpqgSyuC0nMM=; b=MSLjDPzCkGdNQBATeXngbfTKvi7kU89DEpjQ9I+2TkN86lmS207rCUz/cCJYv87liY SnlKrJ/r/0ipJqIBiolj4kSrXZvUPtO1PY7rKP8Bm0x1c66mF02TZREbA+XdnxTVq5ka 3F1dyFrJgdRo3dfRfLMLdMMcO9d8o3sQ2zHPOdDfRWYwU90C4fXqD9hS+bpon6YZjAzN tSzkv2CFjajtVlzPr5wqT6OOqMXnac1S3tvyS7/DvXIELwEBHH31QsyfXcnQS50rDG3m 6IjxzNQ2WyiuOvPzL9H4TCI/vD3mXlJTY9sOyTNMze3V4RH+BRmQWkOghZjox+ePS9Ss dAgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2GNTnUIY; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-150758-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150758-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v12-20020a1709063bcc00b00a51b4613347si1231976ejf.104.2024.04.18.13.40.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:40:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150758-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2GNTnUIY; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-150758-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150758-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B3BAE1F21FDB for ; Thu, 18 Apr 2024 20:40:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9797194C67; Thu, 18 Apr 2024 20:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2GNTnUIY" Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 667BA190690 for ; Thu, 18 Apr 2024 20:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713472820; cv=none; b=GGn3TKlCJWibyg7eEh/rGODYjSFO88YCD3PvSgUYYxjWgfX9fu0MbVZDLA6+CL1Tcgv8n27LLraMkeNn6wqWual5iLF+yzYsOS/H7OEq3y6ItXbOMw9/2ozsKipsYHNqW7x9D0P+V0lw2K6NOX90hh11rjXzxOCnK1F9e04rwDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713472820; c=relaxed/simple; bh=TvHDhStGMQ0UOSySjq/PFonA1j7hVWZ/FBuw6OxGTus=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=PuNOUJxZaPKOWv1sO5PxhM0g71nHkF17FOHDrxZWISffrdSIAEqS8YM0PAgb47shuxADxsPjgB90sbXuS8kgZ1md9ypIR/hD8EtDWeqQtBua/Nta7X7g+VTn0djdw3xtFDveVgfyqBRnrTl3nSGHsiNh5wWBb7EBPHLNkNYP44I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2GNTnUIY; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-346406a5fb9so1047938f8f.1 for ; Thu, 18 Apr 2024 13:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713472818; x=1714077618; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=djyBKRlGRpWDdeJHGkQSaOnuWsBmFhDAvHccO4EOJ1k=; b=2GNTnUIYIcYY0TihbJJ8ApbXq88uLWKaHsADRuuYY4wQxj7MrJPT9yIM74u5G7B644 nYSZQ9xFeecE9ile3y6+la2NK/42797hCwqbhsIWAp4zXv08ptietT2EbBVYBtauE1Jj sYccCLovgQeUOH4t9yOvWH5z6oqYBxPtBt46//IMQxG0iXdIcXVderYZFxXr8G0kbeZI LZLvKWiANt+0PFrYYce+jXUJvT9HqGO4Eh9h/yHB6Yp7aMIMiQVz/O9YOknvCfXMlbMy 0mffzMIj826Cy2pvT7Ph/ODPZ8eisdSsP5toWEsEU2az+k8VRUQL2iiCCBBzAo3R6xMF zh4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713472818; x=1714077618; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=djyBKRlGRpWDdeJHGkQSaOnuWsBmFhDAvHccO4EOJ1k=; b=ZSYxp2C5CaV1BdS+MT5PqOlmt/lQYIL4VdeYT7fGuX/L2+vBkCCUKFkT0MD9fWCpf6 8Fbidj8j87aF5YhEfvBOXr4HQqpHu0rl7jlqsvEN8FGIikIjDec+dn1FbhTMX5T64b0H 2TtdFD7O+uAzMNTCNZoG/QxqZDCjAwkJZZOAhQFGecTSMYtBfyHDzb4Z+kCTHRZxFHKV 96kfd8fP3ltXUmqj1WDfFHOeAkiK9Ztn03/tpdFkN2Dj4+qjmlpNJQuKONNMTMz28TP9 rZnhLlFNrn8+0NrC1QNNAxq3EKXJ+N9cgeE1m60WDIISM72OUX1OVvV7TMfuLGPzXDaN AgQw== X-Forwarded-Encrypted: i=1; AJvYcCX6KylPGgLJiJ3HateZyFxtZJnf3awn7RMBCAZ9EAiHsCLw9t97DV5cFom/H7cUBLUhab6RckDxmlU2QhKejWwKIFi4W3OtTirMDKs2 X-Gm-Message-State: AOJu0YyzUCZJL8xEEI1luzB2DrPkUmJ86mQMVUlW4HMU/j4FcgTYkTKR SZhezxdFK84f3f0RUh3ZXq01xv9EE5AIckcSiMEH5J+a0Vnju7Q/qbS7/Wv9HVeUSvee2y/5fpt kVX7yf2mzyVg2BbhyhqM0Lo7A6b2KNpiRCTbO X-Received: by 2002:a5d:6a07:0:b0:343:77f4:e663 with SMTP id m7-20020a5d6a07000000b0034377f4e663mr37716wru.18.1713472817454; Thu, 18 Apr 2024 13:40:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <171328983017.3930751.9484082608778623495.stgit@firesoul> <171328989335.3930751.3091577850420501533.stgit@firesoul> <651a52ac-b545-4b25-b82f-ad3a2a57bf69@kernel.org> In-Reply-To: From: Yosry Ahmed Date: Thu, 18 Apr 2024 13:39:41 -0700 Message-ID: Subject: Re: [PATCH v1 2/3] cgroup/rstat: convert cgroup_rstat_lock back to mutex To: Shakeel Butt Cc: Jesper Dangaard Brouer , tj@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com, cgroups@vger.kernel.org, longman@redhat.com, netdev@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Arnaldo Carvalho de Melo , Sebastian Andrzej Siewior , mhocko@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 18, 2024 at 7:49=E2=80=AFAM Shakeel Butt wrote: > > On Thu, Apr 18, 2024 at 11:02:06AM +0200, Jesper Dangaard Brouer wrote: > > > > > > On 18/04/2024 04.19, Yosry Ahmed wrote: > [...] > > > > > > I will keep the high-level conversation about using the mutex here in > > > the cover letter thread, but I am wondering why we are keeping the > > > lock dropping logic here with the mutex? > > > > > > > I agree that yielding the mutex in the loop makes less sense. > > Especially since the raw_spin_unlock_irqrestore(cpu_lock, flags) call > > will be a preemption point for my softirq. But I kept it because, we > > are running a CONFIG_PREEMPT_VOLUNTARY kernel, so I still worried that > > there was no sched point for other userspace processes while holding th= e > > mutex, but I don't fully know the sched implication when holding a mute= x. > > > > Are the softirqs you are interested in, raised from the same cpu or > remote cpu? What about local_softirq_pending() check in addition to > need_resched() and spin_needbreak() checks? If softirq can only be > raised on local cpu then convert the spin_lock to non-irq one (Please > correct me if I am wrong but on return from hard irq and not within bh > or irq disabled spin_lock, the kernel will run the pending softirqs, > right?). Did you get the chance to test these two changes or something > similar in your prod environment? I tried making the spinlock a non-irq lock before, but Tejun objected [1]. Perhaps we could experiment with always dropping the lock at CPU boundaries instead? [1]https://lore.kernel.org/lkml/ZBz%2FV5a7%2F6PZeM7S@slm.duckdns.org/