From patchwork Fri Oct 18 09:42:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11197973 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 2579614ED for ; Fri, 18 Oct 2019 09:43:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D03BC20820 for ; Fri, 18 Oct 2019 09:43:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lhD6wCKe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D03BC20820 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 859F88E001F; Fri, 18 Oct 2019 05:43:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7B96B8E0003; Fri, 18 Oct 2019 05:43:27 -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 6FBF28E001F; Fri, 18 Oct 2019 05:43:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 45BF38E0003 for ; Fri, 18 Oct 2019 05:43:27 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id CDCA6181B8ACC for ; Fri, 18 Oct 2019 09:43:26 +0000 (UTC) X-FDA: 76056417612.08.group02_7555b7c2be250 X-Spam-Summary: 2,0,0,2ca656a86020b7b0,d41d8cd98f00b204,3pympxqykcogqvsnobqyyqvo.mywvsxeh-wwufkmu.ybq@flex--glider.bounces.google.com,:glider@google.com:vegard.nossum@oracle.com:dvyukov@google.com:,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2892:2901:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3874:4117:4321:4605:5007:6120:6261:6653:7875:7901:8603:9036:9969:10004:10400:11026:11232:11473:11658:11914:12043:12114:12291:12296:12297:12438:12555:12895:12986:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30034:30054:30064:30075:30090,0,RBL:209.85.221.74:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.175.100 66.100.201.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:26,LUA_SUMMARY:none X-HE-Tag: group02_7555b7c2be250 X-Filterd-Recvd-Size: 6059 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Oct 2019 09:43:26 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id k4so2357027wru.1 for ; Fri, 18 Oct 2019 02:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gPdX/WRj8pZ6Op0hb7v4T/s2H3li4wgFIxE7iLwlBqM=; b=lhD6wCKe/yLpEt6Bnd+BlFsV1+akfNEhtbT6KJMPQ3puuv/hbRWfLQP0YQzhYfGWc9 0JNGR3ahQxZbq+XbkBO5ZjcvA3MpX8QQeV7eQ9YAEsH6a6c7PW/ibqD8d1t94mWDyu9v RZ0p4cJ7mYbdS+esL2vy0USBuKcRW1lh/VrkbklswLO+9T/ZdgHa/+v1fvpxoFxSilaN Kx0WR+Ymdch/kLCaxJ/neGQZgB5qLAnae85csjOuIApZm8A/A0M654/r1sIMVm7DYNZY QRCOBAmfCza222lUyDWPiMBiyznIL+4SkL++YhNMDMd18A2+xhdlqyz3mVcQoQju9ooo gKcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gPdX/WRj8pZ6Op0hb7v4T/s2H3li4wgFIxE7iLwlBqM=; b=ryzqz7BhCZVEkRhsF+8fHCIGIEJtrc63OEQP/wLPOpDG5MT9LwKDXhgWxIRIds3RH8 PU1+nd7KKxf1N5CjLaOynxD2/TH4VtDfCQK84ibPSerJkrQSUPhApraRrlxy5xQ3aVpn nc0MmBZdicTEzr64SH9nGqvads0CweP885WoAv/v+ps7q8CXALEj2aPHB2ETHFYsWG67 c80+qqReowmm5NNLu/1I2lHmxw3N9ygxiHk9uW2j8obvimBSA+i+iy1gySywgo1j7ZzE wu3RGJL8rJb3dTBTH0hW3XDiO9if9WbSMHKxxVOCUeTqjIP+2aUGDD1T2b1uF9RIt+S2 bE2w== X-Gm-Message-State: APjAAAW2NNHCExzvmoVF655BFscABf4wfTnR3eOXgYXkzjS7H0EDCiio 2SybY5IYbs1iOYrGewaf1M/L5orFkAQ= X-Google-Smtp-Source: APXvYqy+p8Fpj+OUm4Ang53HP5c68oXbPSGU4QKJS7p0bYETpigwn3HFUFX2stkzOG/zlSanfyHpKarBwmw= X-Received: by 2002:a5d:4b4c:: with SMTP id w12mr6711737wrs.107.1571391805152; Fri, 18 Oct 2019 02:43:25 -0700 (PDT) Date: Fri, 18 Oct 2019 11:42:42 +0200 In-Reply-To: <20191018094304.37056-1-glider@google.com> Message-Id: <20191018094304.37056-5-glider@google.com> Mime-Version: 1.0 References: <20191018094304.37056-1-glider@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH RFC v1 04/26] stackdepot: reserve 5 extra bits in depot_stack_handle_t From: glider@google.com To: Alexander Potapenko Cc: Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org 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: Some users (currently only KMSAN) may want to use spare bits in depot_stack_handle_t. Let them do so and provide get_dsh_extra_bits() and set_dsh_extra_bits() to access those bits. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: linux-mm@kvack.org --- Change-Id: I23580dbde85908eeda0bdd8f83a8c3882ab3e012 --- include/linux/stackdepot.h | 8 ++++++++ lib/stackdepot.c | 24 +++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 24d49c732341..ac1b5a78d7f6 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -12,6 +12,11 @@ #define _LINUX_STACKDEPOT_H typedef u32 depot_stack_handle_t; +/* + * Number of bits in the handle that stack depot doesn't use. Users may store + * information in them. + */ +#define STACK_DEPOT_EXTRA_BITS 5 depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int nr_entries, gfp_t gfp_flags); @@ -20,5 +25,8 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries); unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); +depot_stack_handle_t set_dsh_extra_bits(depot_stack_handle_t handle, + unsigned int bits); +unsigned int get_dsh_extra_bits(depot_stack_handle_t handle); #endif diff --git a/lib/stackdepot.c b/lib/stackdepot.c index decb1e073b58..460efd3ef742 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -40,8 +40,10 @@ #define STACK_ALLOC_ALIGN 4 #define STACK_ALLOC_OFFSET_BITS (STACK_ALLOC_ORDER + PAGE_SHIFT - \ STACK_ALLOC_ALIGN) + #define STACK_ALLOC_INDEX_BITS (DEPOT_STACK_BITS - \ - STACK_ALLOC_NULL_PROTECTION_BITS - STACK_ALLOC_OFFSET_BITS) + STACK_ALLOC_NULL_PROTECTION_BITS - \ + STACK_ALLOC_OFFSET_BITS - STACK_DEPOT_EXTRA_BITS) #define STACK_ALLOC_SLABS_CAP 8192 #define STACK_ALLOC_MAX_SLABS \ (((1LL << (STACK_ALLOC_INDEX_BITS)) < STACK_ALLOC_SLABS_CAP) ? \ @@ -54,6 +56,7 @@ union handle_parts { u32 slabindex : STACK_ALLOC_INDEX_BITS; u32 offset : STACK_ALLOC_OFFSET_BITS; u32 valid : STACK_ALLOC_NULL_PROTECTION_BITS; + u32 extra : STACK_DEPOT_EXTRA_BITS; }; }; @@ -72,6 +75,24 @@ static int next_slab_inited; static size_t depot_offset; static DEFINE_SPINLOCK(depot_lock); +depot_stack_handle_t set_dsh_extra_bits(depot_stack_handle_t handle, + u32 bits) +{ + union handle_parts parts = { .handle = handle }; + + parts.extra = bits & ((1U << STACK_DEPOT_EXTRA_BITS) - 1); + return parts.handle; +} +EXPORT_SYMBOL_GPL(set_dsh_extra_bits); + +u32 get_dsh_extra_bits(depot_stack_handle_t handle) +{ + union handle_parts parts = { .handle = handle }; + + return parts.extra; +} +EXPORT_SYMBOL_GPL(get_dsh_extra_bits); + static bool init_stack_slab(void **prealloc) { if (!*prealloc) @@ -132,6 +153,7 @@ static struct stack_record *depot_alloc_stack(unsigned long *entries, int size, stack->handle.slabindex = depot_index; stack->handle.offset = depot_offset >> STACK_ALLOC_ALIGN; stack->handle.valid = 1; + stack->handle.extra = 0; memcpy(stack->entries, entries, size * sizeof(unsigned long)); depot_offset += required_size;