From patchwork Fri Oct 16 23:09:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 11842443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A6BF15E6 for ; Fri, 16 Oct 2020 23:09:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B09122201 for ; Fri, 16 Oct 2020 23:09:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eL+60koM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B09122201 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F1E336B0068; Fri, 16 Oct 2020 19:09:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EF5006B006E; Fri, 16 Oct 2020 19:09:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE44A900002; Fri, 16 Oct 2020 19:09:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id AB5E56B0068 for ; Fri, 16 Oct 2020 19:09:40 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4D6358249980 for ; Fri, 16 Oct 2020 23:09:40 +0000 (UTC) X-FDA: 77379332520.01.twist99_610e3d127220 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 1925C100480A0 for ; Fri, 16 Oct 2020 23:09:40 +0000 (UTC) X-Spam-Summary: 1,0,0,93bb8a1d20ee9c6e,d41d8cd98f00b204,jannh@google.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1513:1515:1521:1535:1542:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3871:3874:4321:4385:5007:6120:6261:6653:7875:9592:9969:10004:11658:11914:12043:12048:12296:12297:12517:12519:12555:12895:12986:13138:13231:13618:14096:14181:14721:21080:21444:21451:21627:30054,0,RBL:209.85.221.68:@google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yguuuis41yozownfyzhws86hb8sopaeqpnhdh1bx96wittjnw9fhesinukm5i.qsnga6b5uwnzyx9b9i7rny1iskts7ywy7s35x4bn4mbtz4zi9g1xfidqxzwb1at.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: twist99_610e3d127220 X-Filterd-Recvd-Size: 5169 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 23:09:39 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id t9so4833537wrq.11 for ; Fri, 16 Oct 2020 16:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4LL5NRC0cRVJNqBZIY3Vnesfk3vz5g8to7dyxws6//g=; b=eL+60koMwsyvcjNqBBva4am3HrD7R0Mk/MAMKX69iwE+8LKoVLd4bFn6bE0eHTD1a8 pybTDkHu2I9373x1/HctrF7ICCgGyBGldp0utHtZt+nXoOsQEo0B7ZloQyzhDGnUi4QI ESstpz23vYvfc2rFDn4MEgP6Hs/2gW6xF5W2MdSUjV6bCcE4jebP7DXYCIF3J8wXtaKC vXtM1KDeouCuOfGrPBB6gFrI8L2gf5FYi+HFxNI4B8rJfX+rewKEHzdqvozoItNZgA1O RtR4xP9dXBCq1SDJmnNNeZblxAotKmTItqDdHcoBnlkFHGGlbmlydFNtu3UYZ8gyHQJa IJHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4LL5NRC0cRVJNqBZIY3Vnesfk3vz5g8to7dyxws6//g=; b=WYg5pT/NUBis1juQJlRoIdCiVDTMkxYO9JWnELsgkvOvqyg9hSVG0NzFSUhU0WlpM3 8VVwAuORK2DAPcFWz5OuW5dGQoZgIQN3JBDEHCuGRnXjHhy+x4tZ1JMnJFEtTQw2rOWG kpE8L36gGfY1Aso6thpsxpbs4sXJ8ltTyQK9vjx2pppJRRVef+d1Cdok9CoUbG/b0ozs cXsx4rdh2Ndp4wpVr8tQq/IAYE6cwWEwU1jSycSrjrdYxhoKHUm8logIkiQRkC5duRH9 1sn38jwHw0s+jhgMS6VYP2AX2Po2vfnagL7t8SfhwmI5cSsrzbV8kXHGHIMWECT0zCpa 2CfQ== X-Gm-Message-State: AOAM530bgO19RwxCMD1u2ra0WX46rMc97QWebpEwfGx/uOisCHyLbUj5 rOElSsjP928Sa0/xGNkjcHhfrg== X-Google-Smtp-Source: ABdhPJwutZJE8aiWvcNxtLTRLki2GRNZHZiM+YTPOkZuGIVpCqNB5rDOXOX33qg++t0t+HfIIggPyQ== X-Received: by 2002:adf:f88a:: with SMTP id u10mr6663411wrp.1.1602889778384; Fri, 16 Oct 2020 16:09:38 -0700 (PDT) Received: from localhost ([2a02:168:96c5:1:55ed:514f:6ad7:5bcc]) by smtp.gmail.com with ESMTPSA id n9sm5754512wrq.72.2020.10.16.16.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 16:09:37 -0700 (PDT) From: Jann Horn To: Andrew Morton , linux-mm@kvack.org, Eric Biederman , Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Will Deacon , Kees Cook , Ingo Molnar Subject: [RFC PATCH resend 2/6] refcount: Move refcount_t definition into linux/types.h Date: Sat, 17 Oct 2020 01:09:11 +0200 Message-Id: <20201016230915.1972840-3-jannh@google.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201016230915.1972840-1-jannh@google.com> References: <20201016230915.1972840-1-jannh@google.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: I want to use refcount_t in mm_struct, but if refcount_t is defined in linux/refcount.h, that header would have to be included in linux/mm_types.h; that would be wasteful. Let's move refcount_t over into linux/types.h so that includes can be written less wastefully. Signed-off-by: Jann Horn --- include/linux/refcount.h | 13 +------------ include/linux/types.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/linux/refcount.h b/include/linux/refcount.h index 0e3ee25eb156..fd8cf65e4e2f 100644 --- a/include/linux/refcount.h +++ b/include/linux/refcount.h @@ -96,22 +96,11 @@ #include #include #include +#include /* refcount_t is defined here */ #include struct mutex; -/** - * struct refcount_t - variant of atomic_t specialized for reference counts - * @refs: atomic_t counter field - * - * The counter saturates at REFCOUNT_SATURATED and will not move once - * there. This avoids wrapping the counter and causing 'spurious' - * use-after-free bugs. - */ -typedef struct refcount_struct { - atomic_t refs; -} refcount_t; - #define REFCOUNT_INIT(n) { .refs = ATOMIC_INIT(n), } #define REFCOUNT_MAX INT_MAX #define REFCOUNT_SATURATED (INT_MIN / 2) diff --git a/include/linux/types.h b/include/linux/types.h index a147977602b5..34e4e779e767 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -175,6 +175,18 @@ typedef struct { } atomic64_t; #endif +/** + * struct refcount_t - variant of atomic_t specialized for reference counts + * @refs: atomic_t counter field + * + * The counter saturates at REFCOUNT_SATURATED and will not move once + * there. This avoids wrapping the counter and causing 'spurious' + * use-after-free bugs. + */ +typedef struct refcount_struct { + atomic_t refs; +} refcount_t; + struct list_head { struct list_head *next, *prev; };