Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2669688pxb; Sun, 15 Nov 2020 13:21:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqZTAY6uWeswCx7v5CWIq4DzlEQorlwwp9eSmf5Ur1gneOKOP6WrTmOz/HFaZdj87ZQREA X-Received: by 2002:a17:906:4748:: with SMTP id j8mr11475186ejs.22.1605475272456; Sun, 15 Nov 2020 13:21:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605475272; cv=none; d=google.com; s=arc-20160816; b=luIa5XPRmWOBE8i5kUzb1K4vonNOJbTKQ/GDg0QpV530NSNvGWD8rfP+UOLx8N01+9 QbMxKdSUIcYpHJ8mZWmwPUc4XF9FUrSXzBc7ujNTTauE2T+e/5/UTqifuv+cB6uxCu1+ 4xuRRWHHpMkdm6jHiwX7mvFnBAB0TKdDjO61N6ZQ4brwTab1HTAKFK4PYOjmGihOZU2E xRINT1XKugCuSyVQ3rCt5mktv0PZKZYI/HHLht2OYjvqMv2gcv2JBFkguWRXpcnCGvux VGSHpAanY18Oit7RjTH58XZZQijr3H1rTX96mtkqvrt/bjkF//d3LRmt51UyCrEMAKMT HvOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:to:dkim-signature:dkim-signature:from; bh=LqUSyAUeh+oln8IDe6CcbGx6+YPt/iQBXMlHnjAm338=; b=bWop/nw7VENSzgXWy+FsdUGNjBnno/zbsB9mlUWkXg7dpSvo67uHhZz87Lv2AUpqKF gcMAoeLa6JY8nf1lO8j1HYfAmnS6EzvDOqmZjPxS33iNPIYI3G12Bte/ezRX/gu+0bsh Aa15N4NRk7gaKNglaAhubfpjsBxEp7tRShNcCwcGBGAcB3FyWhoeNomx6Hov3Ev6cuUc LdRNtXZquE8h5ItiEA2IgveDNWAunQt1QadfzBy+UDncz8v29Y1kFQQKxKAJikaa/Yqr C+U46TWyvIil2feD1Piq5OlgJ6DbUbajgzc+CLszpERSRlpRS4Galj6UuXqEgz5s2/vn eQRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="IX/yW47g"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Sv6jyJFg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si3398390ejb.377.2020.11.15.13.19.55; Sun, 15 Nov 2020 13:21:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="IX/yW47g"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Sv6jyJFg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727398AbgKOTnm (ORCPT + 99 others); Sun, 15 Nov 2020 14:43:42 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:36764 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727317AbgKOTnm (ORCPT ); Sun, 15 Nov 2020 14:43:42 -0500 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1605469420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LqUSyAUeh+oln8IDe6CcbGx6+YPt/iQBXMlHnjAm338=; b=IX/yW47ggsZAWS+SrGrHdus69fz9Dz5jUK2A2gXzLIksJaLRZl0/nQ+BoXgGlOl7uGk1R+ TDKGZJ7ZPDSWkxkZObEW3lg8cH5iYHv5xNUtU26tjah/CrYDn74tAxhHboensoD8y7MFAB BX8Aswue7CTArpkszzaw97PXESeExOIe3P90mrS6YaOhVVRLHnhDjnEu9YaPMR58RYyYB7 o7xIYUZdC1rLUA1CRPqnnWDIZ+u7Q/emfRumAHHF8ctSnOrFf4Ln19K5z6SoKxFRZfMHHT 7OCK0XZsz7t4Aql37bqT/h+niLFFlh1yFTsP1jrUovSaA7urXn6GnO0at7iH/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1605469420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LqUSyAUeh+oln8IDe6CcbGx6+YPt/iQBXMlHnjAm338=; b=Sv6jyJFgIxN4azQ59ZsPoJp0ih9bBrK7t8PL+yOCuL2FCzizrdAJiQnR7wpFkY+D/n2QF1 qD7pZXFDSlVFDTDQ== To: Yunfeng Ye , fweisbec@gmail.com, mingo@kernel.org, linux-kernel@vger.kernel.org, Shiyuan Hu , Hewenliang Subject: Re: [PATCH] tick/nohz: Reduce the critical region for jiffies_seq In-Reply-To: References: Date: Sun, 15 Nov 2020 20:43:39 +0100 Message-ID: <87h7pq8kyc.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 11 2020 at 17:11, Yunfeng Ye wrote: > When nohz or nohz_full is configured, the concurrency calls of > tick_do_update_jiffies64 increases, Why? > and the conflict between jiffies_lock and jiffies_seq increases, > especially in multi-core scenarios. This does not make sense. The sequence counter is updated when holding the lock, so there is no conflict between the lock and the sequence count. > However, it is unnecessary to update the jiffies_seq lock multiple > times in a tick period, so the critical region of the jiffies_seq > can be reduced to reduce latency overheads. This does not make sense either. Before taking the lock we have: delta = ktime_sub(now, READ_ONCE(last_jiffies_update)); if (delta < tick_period) return; as a lockless quick check. We also have mechanisms to avoid that a gazillion of CPUs call this. Why are they not working or are some of the callsites missing them? I'm not against reducing the seqcount write scope per se, but it needs a proper and correct explanation. > By the way, last_jiffies_update is protected by jiffies_lock, so > reducing the jiffies_seq critical area is safe. This is misleading. The write to last_jiffies_update is serialized by the jiffies lock, but the write has also to be inside the sequence write held section because tick_nohz_next_event() does: /* Read jiffies and the time when jiffies were updated last */ do { seq = read_seqcount_begin(&jiffies_seq); basemono = last_jiffies_update; basejiff = jiffies; } while (read_seqcount_retry(&jiffies_seq, seq)); So there is no 'By the way'. Thanks, tglx