Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1451137yba; Thu, 9 May 2019 17:20:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGHkr8OrZ0+4u5fX78186MeFZx7VTMUoCoyE+HhTQ+vFNeuDmChhJHK/YadXBM0oYJXtdX X-Received: by 2002:a17:902:7406:: with SMTP id g6mr8770576pll.328.1557447605815; Thu, 09 May 2019 17:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557447605; cv=none; d=google.com; s=arc-20160816; b=Dk2vv+I52F81/hsxuTsuta6ircWD7UilOyoWUnlMFlduD2bX6AQlDi59nC6illSGC7 7euAwdaNpQki+TPIw566fFmNfNKocSRQIPjKYPXDG6joN5zlIPEhZDBgXXxQiXBjiYvr dknNQtVLl2VK1W+2c/EWo2Hbf2J5BMaqtEQ+K76kH4St22JII95/5w9vSQAlQZdco19S ctEklUPZbfjmEacvHsqta1+EoRlbDgz4w6LJwiR8Pkr/zf+QaQKUNPpQYxU0Tf7ZtiyC sdDePKKf7vBBQT7SsHG0QYa/uFX22ayp7IoT06fFbIkErUGJ3hdQ/2Hyy7Qo/kYHlJ+k /JUg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=mw4O6ev32EJop5PfB/p86w6RcybVvIqZIlEya4JoZns=; b=hnmgsdLC8GMsV65f5MEhx0LYnHv9izQ1lFe3MKHvWeGLdwVv355QeewSo+djJc8uwA LE1+TwS5+s0riv4wetLCqucawKwFgjP8++Dd/RwnXhnFgahN3ZL+qIFksX5hk+7yMBeG Ai0oRwD5FuIr2IEB0YWLFeHRB/RTLgkTlj78QYo0tUVvlyKn1C6IwHadSw8wyi7t78Kt LPr/thHgxCmNEZFTo1usIbnf3E4netJaSod4P7PJpJdSPK6rjaAHuqGvAIdoxFj9x8F1 o1j8JidOmLakUVExVInvPnquOeYNiuvMA1wgSLhuT+VKYad1COM14wCSPL7uDdr9TR9u nWCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=J0QYo2X9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si4812552plp.1.2019.05.09.17.19.49; Thu, 09 May 2019 17:20:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=J0QYo2X9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbfEJASi (ORCPT + 99 others); Thu, 9 May 2019 20:18:38 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:52513 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726694AbfEJASi (ORCPT ); Thu, 9 May 2019 20:18:38 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id DE6C422565; Thu, 9 May 2019 20:18:34 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 09 May 2019 20:18:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=mw4O6ev32EJop5PfB /p86w6RcybVvIqZIlEya4JoZns=; b=J0QYo2X9xQcfQjHUMVOu0dP7N5wvkinK/ clSCYYIish7/4Hzs9KTcoofNoY27e+G1NfYBZ5m2k12/n+wzJP6Lx82T4ez3Kzw8 VFJEEDImiYRKqsf1UgJoQupDFRTCn6rBbyvPpXOGFby5FHf+QaxZqaOsw9vupfQ4 vCNdyEcuzYFAVf4BwqPvak/LvIPAPiiGBVr+Edz2z4rGnMzTFykr+8lnGNr0pj0I ECAITX/ypB8YJ1KFMkFI93YjQHH7wCsjui+NQquepUHeYLReuQJj73VhxDGuBRdP CZ+/tetfvErWDA2rKEvGEDD15Kjk3cejCBXaowY8ofbiY4e7EBlrQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrkeeigddufeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpedfvfhosghinhcu vedrucfjrghrughinhhgfdcuoehtohgsihhnsehkvghrnhgvlhdrohhrgheqnecukfhppe duvdegrddujedurddvuddrhedvnecurfgrrhgrmhepmhgrihhlfhhrohhmpehtohgsihhn sehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from eros.localdomain (124-171-21-52.dyn.iinet.net.au [124.171.21.52]) by mail.messagingengine.com (Postfix) with ESMTPA id 1BAC580063; Thu, 9 May 2019 20:18:31 -0400 (EDT) From: "Tobin C. Harding" To: Jonathan Corbet Cc: "Tobin C. Harding" , Corey Minyard , Thomas Hellstrom , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] docs: Move kref.txt to core-api/kref.rst Date: Fri, 10 May 2019 10:17:47 +1000 Message-Id: <20190510001747.8767-1-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 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 kref.txt is already written using correct ReStructuredText format. This can be verified as follows make cleandocs make htmldocs 2> pre.stderr mv Documentation/kref.txt Documentation/core-api/kref.rst // Add 'kref' to core-api/index.rst make cleandocs make htmldocs 2> post.stderr diff pre.stderr post.stderr While doing the file move, fix the column width to be 72 characters wide as it is throughout the document. This is whitespace only. kref.txt is so cleanly written its a shame to have these few extra wide paragraphs. Signed-off-by: Tobin C. Harding --- I'm always hesitant to do docs patches that seem obvious - is there some reason that this was not done previously? I did this one in preparation for converting kobject.txt, my intent is to put kboject.rst in core-api/ also? I can split the whitespace change and the file rename into separate patches if you'd prefer. thanks, Tobin. Documentation/core-api/index.rst | 1 + Documentation/{kref.txt => core-api/kref.rst} | 24 +++++++++---------- Documentation/kobject.txt | 4 ++++ 3 files changed, 17 insertions(+), 12 deletions(-) rename Documentation/{kref.txt => core-api/kref.rst} (93%) diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst index ee1bb8983a88..1c95f0cdd239 100644 --- a/Documentation/core-api/index.rst +++ b/Documentation/core-api/index.rst @@ -34,6 +34,7 @@ Core utilities timekeeping boot-time-mm memory-hotplug + kref Interfaces for kernel debugging diff --git a/Documentation/kref.txt b/Documentation/core-api/kref.rst similarity index 93% rename from Documentation/kref.txt rename to Documentation/core-api/kref.rst index 3af384156d7e..a2174dd09eb2 100644 --- a/Documentation/kref.txt +++ b/Documentation/core-api/kref.rst @@ -230,8 +230,8 @@ of the free operations that could take a long time or might claim the same lock. Note that doing everything in the release routine is still preferred as it is a little neater. -The above example could also be optimized using kref_get_unless_zero() in -the following way:: +The above example could also be optimized using kref_get_unless_zero() +in the following way:: static struct my_data *get_entry() { @@ -261,11 +261,11 @@ the following way:: kref_put(&entry->refcount, release_entry); } -Which is useful to remove the mutex lock around kref_put() in put_entry(), but -it's important that kref_get_unless_zero is enclosed in the same critical -section that finds the entry in the lookup table, -otherwise kref_get_unless_zero may reference already freed memory. -Note that it is illegal to use kref_get_unless_zero without checking its +Which is useful to remove the mutex lock around kref_put() in +put_entry(), but it's important that kref_get_unless_zero is enclosed in +the same critical section that finds the entry in the lookup table, +otherwise kref_get_unless_zero may reference already freed memory. Note +that it is illegal to use kref_get_unless_zero without checking its return value. If you are sure (by already having a valid pointer) that kref_get_unless_zero() will return true, then use kref_get() instead. @@ -312,8 +312,8 @@ locking for lookups in the above example:: kref_put(&entry->refcount, release_entry_rcu); } -But note that the struct kref member needs to remain in valid memory for a -rcu grace period after release_entry_rcu was called. That can be accomplished -by using kfree_rcu(entry, rhead) as done above, or by calling synchronize_rcu() -before using kfree, but note that synchronize_rcu() may sleep for a -substantial amount of time. +But note that the struct kref member needs to remain in valid memory for +a rcu grace period after release_entry_rcu was called. That can be +accomplished by using kfree_rcu(entry, rhead) as done above, or by +calling synchronize_rcu() before using kfree, but note that +synchronize_rcu() may sleep for a substantial amount of time. diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt index ff4c25098119..140030b4603b 100644 --- a/Documentation/kobject.txt +++ b/Documentation/kobject.txt @@ -159,6 +159,10 @@ kernel at the same time, called surprisingly enough kobject_init_and_add():: int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype, struct kobject *parent, const char *fmt, ...); +An error return from kobject_init_and_add() must be followed by a call to +kobject_put() since the 'init' part of this function is always called and the +error return is due to the 'add' part. + The arguments are the same as the individual kobject_init() and kobject_add() functions described above. -- 2.21.0