From: Ingo Molnar <mingo@kernel.org>
To: Dave Hansen <dave@sr71.net>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
dave.hansen@linux.intel.com
Subject: Re: [PATCH 3/3] x86, mpx, selftests: add MPX self test
Date: Wed, 8 Jun 2016 15:29:44 +0200 [thread overview]
Message-ID: <20160608132944.GA18019@gmail.com> (raw)
In-Reply-To: <20160526183616.C73F080F@viggo.jf.intel.com>
These patches look good to me, but it would be nice to get rid of uglies like:
> +/*
> + * Written by Dave Hansen <dave.hansen@intel.com>
> + *
> + * run like this:
> + pid=31390; BDIR="$(cat /proc/$pid/smaps | grep -B1 2097152 | head -1 | awk -F- '{print $1}')"; ./mpx-dig $pid 0x$BDIR
> +
> +NOTE:
> + assumes that the only 2097152-kb VMA is the bounds dir
> + */
(weird vertical alignment)
> +long nr_incore(void *ptr, unsigned long size_bytes)
> +{
> + int i;
> + long ret = 0;
> + long vec_len = size_bytes / PAGE_SIZE;
> + unsigned char *vec = malloc(vec_len);
> + if (!vec)
(missing newline)
> + mpx_dig_abort();
> +
> + int incore_ret = mincore(ptr, size_bytes, vec);
(weird non-kernel-style definition.)
> +char buf[100];
> +int open_proc(int pid, char *file)
(missing newline)
> +{
> + int fd;
> + sprintf(&buf[0], "/proc/%d/%s", pid, file);
(ditto, also unsafe looking sprintf())
> +void __dave_abort(int line)
> +{
> + perror("abort");
> + printf("abort @ %d\n", line);
> + mpx_dig_abort();
> +}
> +#define dave_mpx_dig_abort() __dave_abort(__LINE__);
maybe s/dave// ? ;-)
> +//This mincore stuff works, but the bounds tables are not
> +//sparse enough to make it worthwhile
bad comment style.
> + unsigned char incore_vec[MPX_BOUNDS_TABLE_SIZE_BYTES/ PAGE_SIZE];
> + int incore_ret = mincore(bt_buf, MPX_BOUNDS_TABLE_SIZE_BYTES, &incore_vec[0]);
stray whitespace.
> + //if (!incore_vec[page_nr])
> + // continue;
ugly.
> + if (this_bt_entry_for_vaddr > 0x00007fffffffffffUL) {
> + this_bt_entry_for_vaddr |= 0xffff800000000000;
> + }
unnecessary curly braces.
> + // Each bounds directory entry controls 1MB of
> + // virtual address space. This variable is the
> + // virtual address in the process of the
> + // beginning of the area controlled by this
> + // bounds_dir.
ugly.
> + unsigned long bd_for_vaddr = bd_index * (1UL<<20);
> + //printf("%s() at bd index: %lx for vaddr: %lx\n", __func__, bd_index, bd_for_vaddr);
> + //printf("dir entry[%4ld @ %p]\n", bd_index, bounds_dir_global+i);
Ditto.
> + int nr_entries = dump_table(bounds_dir_entry, bd_for_vaddr, bounds_dir_global+bd_offset_bytes+i);
> + total_entries += nr_entries;
> + continue;
> + printf("dir entry[%4ld @ %p]: 0x%lx %6d entries total this buf: %7d bd_for_vaddrs: 0x%lx -> 0x%lx\n",
> + bd_index, buf+i,
> + bounds_dir_entry, nr_entries, total_entries, bd_for_vaddr, bd_for_vaddr + (1UL<<20));
hm?
> + // there shouldn't practically be short reads of /proc/$pid/mem
> +
> + incore_ret = mincore(dig_bounds_dir_ptr, buffer_size_bytes, &vec[0]);
stray space.
> + //if (this_entries)
> + // printf("entries this loop: %d total: %d (bufs skipped: %d)\n", this_entries, total_entries, bufs_skipped);
You know the drill!
> +#ifdef MPX_DIG_REMOTE
> +int main(int argc, char **argv)
> +{
> + int err;
> + char *c;
hm...
etc. - ad nauseum. Would be nice to tidy this all up a bit.
Thanks,
Ingo
next prev parent reply other threads:[~2016-06-08 13:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 18:36 [PATCH 0/3] x86: compat_siginfo fixes and build-time tests Dave Hansen
2016-05-26 18:36 ` [PATCH 1/3] x86, signals: add missing signal_compat code for x86 features Dave Hansen
2016-05-26 18:36 ` [PATCH 2/3] x86, siginfo: add build-time checks in siginfo compat code Dave Hansen
2016-05-26 18:36 ` [PATCH 3/3] x86, mpx, selftests: add MPX self test Dave Hansen
2016-06-08 13:29 ` Ingo Molnar [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-06-08 17:25 [PATCH 0/3] [v2] x86: compat_siginfo fixes and build-time tests Dave Hansen
2016-06-08 17:25 ` [PATCH 3/3] x86, mpx, selftests: add MPX self test Dave Hansen
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=20160608132944.GA18019@gmail.com \
--to=mingo@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=dave@sr71.net \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.