From: Ingo Molnar <mingo@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
peterz@infradead.org, bp@alien8.de, x86@kernel.org,
linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH] x86/mm/pat: Simplify the free_memtype() control flow
Date: Thu, 21 Nov 2019 17:58:24 +0100 [thread overview]
Message-ID: <20191121165824.GA12042@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1911201901270.29534@nanos.tec.linutronix.de>
* Thomas Gleixner <tglx@linutronix.de> wrote:
> On Mon, 21 Oct 2019, Davidlohr Bueso wrote:
> > int rbt_memtype_check_insert(struct memtype *new,
> > enum page_cache_mode *ret_type)
> > {
> > int err = 0;
> >
> > err = memtype_rb_check_conflict(&memtype_rbroot, new->start, new->end,
> > - new->type, ret_type);
> > -
> > - if (!err) {
> > - if (ret_type)
> > - new->type = *ret_type;
> > -
> > - new->subtree_max_end = new->end;
> > - memtype_rb_insert(&memtype_rbroot, new);
> > - }
> > + new->type, ret_type);
> > + if (err)
> > + goto done;
>
> Please return err here. That goto is pointless.
>
> > +
> > + if (ret_type)
> > + new->type = *ret_type;
> > + memtype_interval_insert(new, &memtype_rbroot);
> > +done:
> > return err;
> > }
>
> Other than that.
>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Thanks - I rebased the v2 version in x86/mm with this cleanup included.
Two days ago I noticed a similarly quirky control flow in free_memtype()
as well, and fixed it via the patch below.
Ingo
==============>
From: Ingo Molnar <mingo@kernel.org>
Date: Tue, 19 Nov 2019 10:18:56 +0100
Subject: [PATCH] x86/mm/pat: Simplify the free_memtype() control flow
Simplify/streamline the quirky handling of the pat_pagerange_is_ram() logic,
and get rid of the 'err' local variable.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/mm/pat.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index ea7da7e62e17..af049920e59a 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -656,7 +656,6 @@ int reserve_memtype(u64 start, u64 end, enum page_cache_mode req_type,
int free_memtype(u64 start, u64 end)
{
- int err = -EINVAL;
int is_range_ram;
struct memtype *entry;
@@ -671,14 +670,10 @@ int free_memtype(u64 start, u64 end)
return 0;
is_range_ram = pat_pagerange_is_ram(start, end);
- if (is_range_ram == 1) {
-
- err = free_ram_pages_type(start, end);
-
- return err;
- } else if (is_range_ram < 0) {
+ if (is_range_ram == 1)
+ return free_ram_pages_type(start, end);
+ if (is_range_ram < 0)
return -EINVAL;
- }
spin_lock(&memtype_lock);
entry = memtype_erase(start, end);
next prev parent reply other threads:[~2019-11-21 16:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 23:19 [PATCH -tip v2 0/4] x86,mm/pat: Move towards using generic interval tree Davidlohr Bueso
2019-10-21 23:19 ` [PATCH 1/4] x86/mm, pat: Convert pat tree to " Davidlohr Bueso
2019-11-20 18:05 ` Thomas Gleixner
2019-11-21 16:58 ` Ingo Molnar [this message]
2019-11-21 6:03 ` [tip: x86/mm] x86/mm/pat: Convert the PAT tree to a " tip-bot2 for Davidlohr Bueso
2019-10-21 23:19 ` [PATCH 2/4] x86,mm/pat: Cleanup some of the local memtype_rb_* calls Davidlohr Bueso
2019-11-20 18:06 ` Thomas Gleixner
2019-11-21 6:03 ` [tip: x86/mm] x86/mm/pat: Clean up some of the local memtype_rb_*() calls tip-bot2 for Davidlohr Bueso
2019-10-21 23:19 ` [PATCH 3/4] x86,mm/pat: Drop rbt suffix from external memtype calls Davidlohr Bueso
2019-11-20 18:07 ` Thomas Gleixner
2019-11-21 6:03 ` [tip: x86/mm] x86/mm/pat: Drop the rbt_ prefix from external memtype function names tip-bot2 for Davidlohr Bueso
2019-10-21 23:19 ` [PATCH 4/4] x86/mm, pat: Rename pat_rbtree.c to pat_interval.c Davidlohr Bueso
2019-11-19 8:17 ` Ingo Molnar
2019-11-19 17:16 ` Davidlohr Bueso
2019-11-21 6:03 ` [tip: x86/mm] x86/mm/pat: " tip-bot2 for Davidlohr Bueso
[not found] ` <CAHk-=wg565YQe6Dmpjg6QJ9aPHvkT7G60iDYS12TZoG+q+hbTw@mail.gmail.com>
2019-11-21 17:08 ` Ingo Molnar
2019-11-18 15:41 ` [PATCH -tip v2 0/4] x86,mm/pat: Move towards using generic interval tree Davidlohr Bueso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191121165824.GA12042@gmail.com \
--to=mingo@kernel.org \
--cc=bp@alien8.de \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).