From owner-svn-src-head@freebsd.org Sat Oct 14 18:03:13 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8DDF0E28A1C; Sat, 14 Oct 2017 18:03:13 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5A6A8771AE; Sat, 14 Oct 2017 18:03:13 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pf0-x241.google.com with SMTP id z11so12774798pfk.4; Sat, 14 Oct 2017 11:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CUIss13Wa8vx+Oci+FoPgz43g4shiToZEU6EoGW64+4=; b=ghgU3aR4xZo7Mb73daflc5gj3wjF1d2QMvGtJm39TX7csOxLD4e1BHzIUix/JQfNUp WMk+s7qqAZ3GzUnjhPdzn3f0551Bf3An6oC1JeIjbnIhTpKBXnjY3TX9QvIEt29o6DGb jEdymFDiwka/9tiPxFv1okHc8VZUTs6c+6q3yx3049ZFNOV0zzus+NAGEkKV8w51YbJK kmAcnRPBFB0YBBsEwkLW/sYeJzVrzFc5/LjPid2xzAMUgIV+3NtrBGljYvtEPyqvnGk1 LW6HuMzaOEDDj86zDBcrWMWiNwFmkMwwZWuazc4N9SvkVRuWGJ/CestxkQopmyZI2cu9 W2AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=CUIss13Wa8vx+Oci+FoPgz43g4shiToZEU6EoGW64+4=; b=TDR3kgqJGCYpUguirnGpNW7qcobX6oJvKRhMno4PLfPFkAfyqFj7w8aXhisleKRVc8 CPN/3qAAaQQ/WUj8UwvNsmsIGeqTlDNvsA+wlRVHvh4jSIAJbsmqbbOKCGn/fneMEu0n MjIR9Sa3uRZ5ojOKAFr7rx7d/OWu1FJBHqyiXnAMkxLCDhq+6uQ/5BOvPyPuyra9DHIT hPMO1s102geqvOWfmq3uC1FTc/lFNEtIW+EtlOBLZoil5EW1TAM8iLGS0Rn7SUNNkWLL cXBbmoGBCgQLKrY9ev0RR6pdiujQaEBMUUze10mJ2bXZ313S82gfVhf5HC8D262lzz/3 iwQA== X-Gm-Message-State: AMCzsaVYH6XNpHhrO0dA+7OUH9Zpai+xdDEt/bMv1VNe0fjfjuSHODWz CFhmR/uACX83jwUB+dx4Giz8fw== X-Google-Smtp-Source: AOwi7QBd6FiS717/dtw2AwF8biBVTsIYmF3wkX6brA5S7lBLE3+UvZpzUmpJxZT6i4uk7cpDRDsF1Q== X-Received: by 10.84.246.204 with SMTP id j12mr4598153plt.240.1508004192411; Sat, 14 Oct 2017 11:03:12 -0700 (PDT) Received: from raichu (toroon0560w-lp140-01-69-159-39-234.dsl.bell.ca. [69.159.39.234]) by smtp.gmail.com with ESMTPSA id c73sm9306691pfd.139.2017.10.14.11.03.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Oct 2017 11:03:10 -0700 (PDT) Sender: Mark Johnston Date: Sat, 14 Oct 2017 14:03:05 -0400 From: Mark Johnston To: Matt Joras Cc: "Ngie Cooper (yaneurabeya)" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r324541 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20171014180305.GA75158@raichu> References: <201710112153.v9BLroeR007323@repo.freebsd.org> <365AD758-5761-4BD4-A80E-8EF2EA84EAAA@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Oct 2017 18:03:13 -0000 On Fri, Oct 13, 2017 at 10:36:26PM -0700, Matt Joras wrote: > On 10/13/2017 22:12, Ngie Cooper (yaneurabeya) wrote: > >> Modified: head/sys/kern/subr_unit.c > >> ============================================================================== > >> --- head/sys/kern/subr_unit.c Wed Oct 11 20:36:22 2017 (r324540) > >> +++ head/sys/kern/subr_unit.c Wed Oct 11 21:53:50 2017 (r324541) > >> @@ -366,6 +366,27 @@ delete_unrhdr(struct unrhdr *uh) > >> Free(uh); > >> } > >> > >> +void > >> +clear_unrhdr(struct unrhdr *uh) > >> +{ > >> + struct unr *up, *uq; > >> + > >> + KASSERT(TAILQ_EMPTY(&uh->ppfree), > >> + ("unrhdr has postponed item for free")); > >> + up = TAILQ_FIRST(&uh->head); > >> + while (up != NULL) { > > Could this be done with TAILQ_FOREACH_SAFE? > > -Ngie > > > Yes but it is arguably inferior to do so. This while loop is > theoretically faster since there is no need to individually remove the > elements when you intend to delete every element. TAILQ_FOREACH_SAFE just fetches the next element at the beginning of each loop iteration rather than at the end, same as the current implementation of clear_unrhdr() does. There's no change to the code generated by clang when I replace your loop with: TAILQ_FOREACH_SAFE(up, &uh->head, list, uq) { if (up->ptr != uh) { Free(up->ptr); } Free(up); }