Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp43447imm; Tue, 31 Jul 2018 13:29:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2iUEcQR0XGU/WraPuyNIRjjNF1aI1sgXOBqGrRsjKTjQaCoLff3bGL71p0dfo7vOVO4of X-Received: by 2002:a62:9541:: with SMTP id p62-v6mr23553094pfd.152.1533068944552; Tue, 31 Jul 2018 13:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533068944; cv=none; d=google.com; s=arc-20160816; b=iddPQxcK5NKBwb0CSgE/WapWLcUHe6TulXnMuKjNuRPZX9ceCwM4FUdQEbZ1sQw55j ol1F78rWGKvjs+pSBrufV0IvNocgWgJQipJq+lLoEKw/5AsMrqTF1P/5Ay+KIm+9NNj+ hQBvmHpgxPIlUaE5+p7nKVys/849S5ksPGB8V28a+slD/lVCHzJMCqixIHswYBfoyArD GA9koofERO6NoFZX1mdQqguIp+9FMCOg9NiYM5xiYlHGO12Mofx/PUEfq4n+5b/V7Bxh NgcaFDm5/4tn50iZhOTvaf6PuMWnmeEL4rcn/0Eq46vFTufFF7HMHRlEIqtkkRLOMrzN 0/WQ== 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:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=jvFeZXrk3oKikBKgA6HGG1zqb2rUCE9zVZ5+CocYrd0=; b=JUY64ZIP6RGRMBIa/KkUSb8wzcvUMHQVfg/tpIFo2Hs3MAhP3/dg9Y0nnSRp+v90oR QkWtGCK+jhP/lRb7O0RvV0B2J0Cbr9esxkKTdBFn6kyNBbVrxKSe5P5UwZz/Qu38oTn0 446CFoVEO6Ueb45WSJ48AJK7uoZmXmpAkubu4R4n4yamuJZJ6J0Aj2nDHBtFnIGqVTtE QGW8nBMUsYtSYhg5TudhyX2JPBEhNGQu5TMwZ2Us3wDBgoimKFLkAr/K+P+q6uHwJdix P1j2y4dXhmDK2ju0BGu8obD9yoLD8dQlE2No744Zrf6+McfOPVv3IO+0/gYjfFyyiVUL oN4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=mfCJ2nTD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si14561702pgr.68.2018.07.31.13.28.44; Tue, 31 Jul 2018 13:29:04 -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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=mfCJ2nTD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732164AbeGaWJI (ORCPT + 99 others); Tue, 31 Jul 2018 18:09:08 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43650 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727076AbeGaWJI (ORCPT ); Tue, 31 Jul 2018 18:09:08 -0400 Received: by mail-pg1-f194.google.com with SMTP id d17-v6so5195458pgv.10 for ; Tue, 31 Jul 2018 13:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jvFeZXrk3oKikBKgA6HGG1zqb2rUCE9zVZ5+CocYrd0=; b=mfCJ2nTDWD9WuQ/sE+y4Et5i27NIiPtxDTgTCW/9PU/HnGmyfWtukUYhTepiyRkqQE fH0piCszw3Jf2AkcstdjhKbfo3v7Lfm0mtx4Gje+WGWGD5/Wj+64ie9MohCmn9eKsInJ SwJykvQezW6y0etkq9z1Pi1Q/GmuaRyYOy1y6hMAAzHBrWo2+EpjkMy191/1uZXH0l6O SmchUY9b22aSLFgAReT7WEYRVlPg4M50AaW7dbFvWnPNIgEXQUDpt14SNNJ0xAMQCVFA CEuYyvlo5+5b5A88RLNCAzz6sfgnYAdwCDA8Tb2wlqhgtu/EjSmr8GST7rVhXJABYPLv RTIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jvFeZXrk3oKikBKgA6HGG1zqb2rUCE9zVZ5+CocYrd0=; b=jDnDEiLqgOs9TvUUvIYxvVE+JY09MCLTC0Z2zfTrnqmlIpEp761vOi1uZt1/BLVvqr ldOYtLrvb+j6SLieR20hz6YZ4YcPQSO/vLuOH7wKDxxXKLveW0fSYY8mFmODedxrgFGU nXbeoRW9624QwEvDBe0g3jKcrLEO5yUmUnJbTL8wLB3rSHCV+SxIAiG5mD2ohwCDi/zM i2BB9Hg4QA3YMbHHz+ydJcihqmXDwehf8HiSIeJNhOnpRrueFfa0x37we54+eV5B2Fqv 7bE8x3qE/JebyaF8Gkvv35ZuLSy8Vp8lVlgYqB2nwh/RAaOO5wdvRA7+atTka3jK8WWi Utdw== X-Gm-Message-State: AOUpUlFqXQHNuZJtjEpCdZFbtr+ROIFMBEWNjzCbX62/juMlx9WL9bPJ M7l1bTDqWXW/D+IXaju9Isv5NQ== X-Received: by 2002:a65:4849:: with SMTP id i9-v6mr21802128pgs.350.1533068824818; Tue, 31 Jul 2018 13:27:04 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id u83-v6sm2025493pfj.37.2018.07.31.13.27.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 13:27:04 -0700 (PDT) Date: Tue, 31 Jul 2018 13:27:01 -0700 From: Stephen Hemminger To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, davem@davemloft.net, Greg KH Subject: Re: [PATCH v1 3/3] net: WireGuard secure network tunnel Message-ID: <20180731132701.522b55e2@xeon-e3> In-Reply-To: <20180731191102.2434-4-Jason@zx2c4.com> References: <20180731191102.2434-1-Jason@zx2c4.com> <20180731191102.2434-4-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 31 Jul 2018 21:11:02 +0200 "Jason A. Donenfeld" wrote: > +#define push(stack, p, len) ({ \ > + if (rcu_access_pointer(p)) { \ > + BUG_ON(len >= 128); \ > + stack[len++] = rcu_dereference_protected(p, lockdep_is_held(lock)); \ > + } \ > + true; \ > +}) > +static void free_root_node(struct allowedips_node __rcu *top, struct mutex *lock) > +{ > + struct allowedips_node *stack[128], *node; > + unsigned int len; > + > + for (len = 0, push(stack, top, len); len > 0 && (node = stack[--len]) && push(stack, node->bit[0], len) && push(stack, node->bit[1], len);) > + call_rcu_bh(&node->rcu, node_free_rcu); > +} This looks like you are doing traversal to free a tree. The stack is there so that you do the rcu callbacks in the proper order. Won't this create an lot of RCU work at once?