Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp31464ybh; Mon, 20 Jul 2020 09:36:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgUTcwEAg4RcQBTdWzdRK4uIpFrugZvH3BS+33fab729J1ybO628ZS4bITze1BhyLZDEFg X-Received: by 2002:a17:906:f20d:: with SMTP id gt13mr21843946ejb.117.1595262963128; Mon, 20 Jul 2020 09:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595262963; cv=none; d=google.com; s=arc-20160816; b=vR2TNIvvdfXyGTYujJURk7kru0LTjJe0eeYeUgQL515S/0t6NLw6mpj+AiP/g+h0vc l0FEumLeiQgZjUY+ctipvTc9vgDXheFZXG8sFzluQFUH2kde3KScBoLANQj30WVueZXv Y58OUYJ8rknnbwSLNpWoCCuKtQnb2/Ihx0PN4eEQECKiAjGJ14efHZ5vwgFmvsSyadTW +EUqQBUj/2CLXKwMoP0cbCO+e4tFFoT783ICpKMSgx5+U8b5TU1yKcT1KKz7rNbBh2b8 qMlcNMwzdglSk8asL1xX6DW+vE+RlI9UrXSjl7nNKg/TGH0dX5RM2CsDkjMxTZhecP/B xK1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=osTtrNUr4OHk/B4zAgkYVq1r5kpsvFsCr0rPGrUYJ3o=; b=LscbDCMFaokO2Lj5uh4Vw4nNtsTYxEpdhXQRQyWXOYA5aRC1/8pOKARAT7eFt/5KhP zE1anREQzEd1yeh33j7/1Q4H563sxXnbLHphPXFhRXh6mhMOm5HLNKSJ0WIOPHjIpYEJ eXUFdT5w1Fwl/Vih/A/mq9SnwOryFT8blXrh7Tk+RvQ4fZRu/BhYNCUOHG5NUtlH6bbX +D7guRf9d0w3ScGCS8UcbbYBW5YcC/i2Ui4FO6Oo6a7hMC+JRWXvif7HY1JTXXA3bHLM 4oHWzKrlgE2qFCDJhN0ZKDXh9nIJb+X7a/jnZdbO77We0qGxjYcrxjqhadyaZFPfkVSw aCew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="cVVTSp/y"; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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 p7si10706782edm.514.2020.07.20.09.35.36; Mon, 20 Jul 2020 09:36:03 -0700 (PDT) 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="cVVTSp/y"; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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 S1731504AbgGTPzs (ORCPT + 99 others); Mon, 20 Jul 2020 11:55:48 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:58700 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731225AbgGTPzn (ORCPT ); Mon, 20 Jul 2020 11:55:43 -0400 From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595260541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=osTtrNUr4OHk/B4zAgkYVq1r5kpsvFsCr0rPGrUYJ3o=; b=cVVTSp/yxcUkuUT49JWGd0r+9986GyT5GOZQD6zLLS7JkcAKnHGz9oYf1FP67YJ6amNKfx wj/IxFAlJW4QYey51hJ5jShODthCuI4yn7Ofmpak9lFjDU8+T/nFn9//xthonl2FzFRNJf Z+8q17yC3OcApu1DrgwhcLWm5006nD7evxF49tPLb9jRZFKmRya/29bFsVBRWyiwVwbfvb 6XnSj358njN6AJgxEqxozYLM/J4z/fS9zIuXpBlWwBXJB2NFRDt07mueqs1sR441EGYrIy tA8QYdZP4XinaOsRkb2BYdlt1OTM+6AudDclRB5OVSllsXRmChIyWLehTXh4hg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595260541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=osTtrNUr4OHk/B4zAgkYVq1r5kpsvFsCr0rPGrUYJ3o=; b=KkPA6RbwZMRD0z7JCvjKoZ5vai1cuanX0ola+cD+7oYDkJwTyjNpjUeA+gHtGdEIHNyfdu u6bZViCZw/6soPAA== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , "Ahmed S. Darwish" , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH v4 02/24] seqlock: Properly format kernel-doc code samples Date: Mon, 20 Jul 2020 17:55:08 +0200 Message-Id: <20200720155530.1173732-3-a.darwish@linutronix.de> In-Reply-To: <20200720155530.1173732-1-a.darwish@linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200720155530.1173732-1-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Align the code samples and note sections inside kernel-doc comments with tabs. This way they can be properly parsed and rendered by Sphinx. It also makes the code samples easier to read from text editors. Signed-off-by: Ahmed S. Darwish --- include/linux/seqlock.h | 108 +++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 299d68f10325..6c4f68ef1393 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -263,32 +263,32 @@ static inline void raw_write_seqcount_end(seqcount_t *s) * atomically, avoiding compiler optimizations; b) to document which writes are * meant to propagate to the reader critical section. This is necessary because * neither writes before and after the barrier are enclosed in a seq-writer - * critical section that would ensure readers are aware of ongoing writes. + * critical section that would ensure readers are aware of ongoing writes:: * - * seqcount_t seq; - * bool X = true, Y = false; + * seqcount_t seq; + * bool X = true, Y = false; * - * void read(void) - * { - * bool x, y; + * void read(void) + * { + * bool x, y; * - * do { - * int s = read_seqcount_begin(&seq); + * do { + * int s = read_seqcount_begin(&seq); * - * x = X; y = Y; + * x = X; y = Y; * - * } while (read_seqcount_retry(&seq, s)); + * } while (read_seqcount_retry(&seq, s)); * - * BUG_ON(!x && !y); + * BUG_ON(!x && !y); * } * * void write(void) * { - * WRITE_ONCE(Y, true); + * WRITE_ONCE(Y, true); * - * raw_write_seqcount_barrier(seq); + * raw_write_seqcount_barrier(seq); * - * WRITE_ONCE(X, false); + * WRITE_ONCE(X, false); * } */ static inline void raw_write_seqcount_barrier(seqcount_t *s) @@ -325,64 +325,68 @@ static inline int raw_read_seqcount_latch(seqcount_t *s) * Very simply put: we first modify one copy and then the other. This ensures * there is always one copy in a stable state, ready to give us an answer. * - * The basic form is a data structure like: + * The basic form is a data structure like:: * - * struct latch_struct { - * seqcount_t seq; - * struct data_struct data[2]; - * }; + * struct latch_struct { + * seqcount_t seq; + * struct data_struct data[2]; + * }; * * Where a modification, which is assumed to be externally serialized, does the - * following: + * following:: * - * void latch_modify(struct latch_struct *latch, ...) - * { - * smp_wmb(); <- Ensure that the last data[1] update is visible - * latch->seq++; - * smp_wmb(); <- Ensure that the seqcount update is visible + * void latch_modify(struct latch_struct *latch, ...) + * { + * smp_wmb(); // Ensure that the last data[1] update is visible + * latch->seq++; + * smp_wmb(); // Ensure that the seqcount update is visible * - * modify(latch->data[0], ...); + * modify(latch->data[0], ...); * - * smp_wmb(); <- Ensure that the data[0] update is visible - * latch->seq++; - * smp_wmb(); <- Ensure that the seqcount update is visible + * smp_wmb(); // Ensure that the data[0] update is visible + * latch->seq++; + * smp_wmb(); // Ensure that the seqcount update is visible * - * modify(latch->data[1], ...); - * } + * modify(latch->data[1], ...); + * } * - * The query will have a form like: + * The query will have a form like:: * - * struct entry *latch_query(struct latch_struct *latch, ...) - * { - * struct entry *entry; - * unsigned seq, idx; + * struct entry *latch_query(struct latch_struct *latch, ...) + * { + * struct entry *entry; + * unsigned seq, idx; * - * do { - * seq = raw_read_seqcount_latch(&latch->seq); + * do { + * seq = raw_read_seqcount_latch(&latch->seq); * - * idx = seq & 0x01; - * entry = data_query(latch->data[idx], ...); + * idx = seq & 0x01; + * entry = data_query(latch->data[idx], ...); * - * smp_rmb(); - * } while (seq != latch->seq); + * smp_rmb(); + * } while (seq != latch->seq); * - * return entry; - * } + * return entry; + * } * * So during the modification, queries are first redirected to data[1]. Then we * modify data[0]. When that is complete, we redirect queries back to data[0] * and we can modify data[1]. * - * NOTE: The non-requirement for atomic modifications does _NOT_ include - * the publishing of new entries in the case where data is a dynamic - * data structure. + * NOTE: * - * An iteration might start in data[0] and get suspended long enough - * to miss an entire modification sequence, once it resumes it might - * observe the new entry. + * The non-requirement for atomic modifications does _NOT_ include + * the publishing of new entries in the case where data is a dynamic + * data structure. * - * NOTE: When data is a dynamic data structure; one should use regular RCU - * patterns to manage the lifetimes of the objects within. + * An iteration might start in data[0] and get suspended long enough + * to miss an entire modification sequence, once it resumes it might + * observe the new entry. + * + * NOTE: + * + * When data is a dynamic data structure; one should use regular RCU + * patterns to manage the lifetimes of the objects within. */ static inline void raw_write_seqcount_latch(seqcount_t *s) { -- 2.20.1