From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CFB2C433EF for ; Tue, 8 Feb 2022 21:01:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61E3C6B0074; Tue, 8 Feb 2022 16:01:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CD906B0075; Tue, 8 Feb 2022 16:01:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46DC06B0078; Tue, 8 Feb 2022 16:01:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id 346FB6B0074 for ; Tue, 8 Feb 2022 16:01:24 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E8987998D9 for ; Tue, 8 Feb 2022 21:01:23 +0000 (UTC) X-FDA: 79120833246.07.43C42AC Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) by imf12.hostedemail.com (Postfix) with ESMTP id 982B74000F for ; Tue, 8 Feb 2022 21:01:23 +0000 (UTC) Received: by mail-yb1-f180.google.com with SMTP id y203so163366yby.11 for ; Tue, 08 Feb 2022 13:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eclypsium.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0l/46u8AZdLsXUbvuQUU485sD3pVp7EO/xSTTeL7cJM=; b=I6UYi9kkOMT9ddLuK3RphTOoWfxZRmyQVibkm2fFhnajqkBSlf14Q7WYN/fGMFsDli DE2IgaJM90B361A7HdTnYwS8c2La3jGWOSzjm2JcfQBstBkNZU++5vi1sEqHSRK3f/Yv MZAWCl3PHgpp8rVOCJwsvi2/nnii0OgHVhLdBejC3n1KxAp/1VrWLACdwFQxjPuWTNXk rKYBSYZuqVjd1RnA5Q99LfnwZADSRC2oIxTuwWNqzAEocO+OJn0qLwMkq3v3T/robeFM naj0UCn+AkfURPzWzOTp1GFHB4QYdTRo3pV7xDlpscDMnJ74+1tDLCZFlimNvvT3YEZn 1OxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0l/46u8AZdLsXUbvuQUU485sD3pVp7EO/xSTTeL7cJM=; b=YAfAck7zwjmRelbMbOuvC2aAfoKXKlnQ5vSSDvKbAqQSSy/tA4syMX+qjHLxenW8Zn CXZg3AXfgtz7inJh8SE2JcpQJ3LMN40MzyK+Fcizl7B8WYG1oV4Qb9jwqGRJUvxswaWc DXpJPTdHRLkBFX+Q9LS4n7SNHB4F3xdZ9lZQWzoZiGBwOFAqS3SNHZ8ZLZAPVbmB2CK5 Jq1/ytk7WupK9anE1epNGp0agtmmDxMraWSlGe2XziF8aSb7lPgA/zJFKNXk2JAy/+Qm JSkp5ZX0NdO4bSKbUJalTRylC6Cbqn4zKU7xlK35DIKQ9qYcXLc9wOQfGjKq0d+dD+2a 4+Hw== X-Gm-Message-State: AOAM530mcH5n6BbTsQRQVpNHmwzJsf697hCdMd7JGK2vhAViq6aqkNZd GALKMW1csHmF866Rof9l/oWm1OnOByk38TbqCUU1OA== X-Google-Smtp-Source: ABdhPJxEEHahkNZiuy7H+1EBwmPjo/Hl9B+TdeAPt4ZWDB5jM93kJLOKDwL5ViCTTyBQvySlw0bxY+shfJhBtj+ozkY= X-Received: by 2002:a25:abaa:: with SMTP id v39mr6351030ybi.393.1644354082773; Tue, 08 Feb 2022 13:01:22 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a81:174d:0:0:0:0:0 with HTTP; Tue, 8 Feb 2022 13:01:21 -0800 (PST) In-Reply-To: References: <20220203164328.203629-1-martin.fernandez@eclypsium.com> <20220203164328.203629-4-martin.fernandez@eclypsium.com> <202202071325.F8450B3B2D@keescook> From: Martin Fernandez Date: Tue, 8 Feb 2022 18:01:21 -0300 Message-ID: Subject: Re: [PATCH v6 3/6] x86/e820: Refactor range_update and range_remove To: Mike Rapoport Cc: Kees Cook , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, ardb@kernel.org, dvhart@infradead.org, andy@infradead.org, gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.org, daniel.gutson@eclypsium.com, hughsient@gmail.com, alex.bazhaniuk@eclypsium.com, alison.schofield@intel.com Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=eclypsium.com header.s=google header.b=I6UYi9kk; dmarc=pass (policy=quarantine) header.from=eclypsium.com; spf=pass (imf12.hostedemail.com: domain of martin.fernandez@eclypsium.com designates 209.85.219.180 as permitted sender) smtp.mailfrom=martin.fernandez@eclypsium.com X-Rspamd-Server: rspam03 X-Rspam-User: X-Stat-Signature: ut3f3cecs9i3mpiizegga9zc6pjxzpyu X-Rspamd-Queue-Id: 982B74000F X-HE-Tag: 1644354083-564861 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: On 2/8/22, Mike Rapoport wrote: > On Mon, Feb 07, 2022 at 01:45:40PM -0800, Kees Cook wrote: >> On Thu, Feb 03, 2022 at 01:43:25PM -0300, Martin Fernandez wrote: >> > __e820__range_update and e820__range_remove had a very similar >> > implementation with a few lines different from each other, the lines >> > that actually perform the modification over the e820_table. The >> > similiraties were found in the checks for the different cases on how >> > each entry intersects with the given range (if it does at all). These >> > checks were very presice and error prone so it was not a good idea to >> > have them in both places. >> >> Yay removing copy/paste code! :) > > Removing copy/paste is nice but diffstat of > > arch/x86/kernel/e820.c | 383 ++++++++++++++++++++++++++++++----------- > 1 file changed, 283 insertions(+), 100 deletions(-) > > does not look nice even accounting for lots of comments :( > > I didn't look closely, but diffstat clues that the refactoring making > things much more complex. > Yes, that diffstat surprised me as well. I have to mention that 110 of those lines are kerneldocs and blank lines, which is quite a lot. Also you have to take into account that I expanded most of the function definitions for better formatting, which also took some space. And as I was able to focus the "hard" part of the problem into a single function, testing can be done easily as Kees suggested and I'm planning to do so in the next patch.