mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian Hansen (chansen3)" <chansen3@cisco.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "xe-linux-external(mailer list)" <xe-linux-external@cisco.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tools: adding support for idle page tracking to tool
Date: Thu, 5 Jul 2018 18:14:17 +0000	[thread overview]
Message-ID: <5F15F2EE-61F9-4E6F-99B2-B417B02C0F19@cisco.com> (raw)
In-Reply-To: <20180619153911.bd835e2a7f0a4d2d3cddf348@linux-foundation.org>

Yes, I wasn't sure which one went in first.  I can make this one dependent on the other.

On 2018-06-19, 6:39 PM, "Andrew Morton" <akpm@linux-foundation.org> wrote:

    On Tue, 12 Jun 2018 11:32:23 -0400 Christian Hansen <chansen3@cisco.com> wrote:
    
    > Adding a flag which will use the kernels's idle
    > page tracking to mark pages idle.  As the tool already
    > prints the idle flag if set, subsequent runs will show
    > which pages have been accessed since last run.
    
    That sounds useful.
    
    This patch seems to have been prepared against the mainline kernel, so
    it conflicts with your "tools: modifying page-types to include shared
    map counts" patch.  Awkward, but I seem to have got it fixed up.
    
    > ...
    >
    > @@ -566,6 +570,30 @@ static int unpoison_page(unsigned long offset)
    >  	return 0;
    >  }
    >  
    > +static int mark_page_idle(unsigned long offset)
    > +{
    > +	static unsigned long off;
    > +	static uint64_t buf;
    > +	int len;
    > +
    > +	if ((offset / 64 == off / 64) || buf == 0) {
    > +		buf |= 1UL << (offset % 64);
    > +		off = offset;
    > +		return 0;
    > +	}
    > +
    > +	len = pwrite(page_idle_fd, &buf, 8, 8 * (off / 64));
    > +	if (len < 0) {
    > +		perror("mark page idle");
    > +		return len;
    > +	}
    > +
    > +	buf = 1UL << (offset % 64);
    > +	off = offset;
    > +
    > +	return 0;
    > +}
    
    This is a bit cumbersome.  Why not this way:
    
    static int mark_page_idle(unsigned long offset)
    {
    	static unsigned long off;
    	static uint64_t buf;
    	int len;
    
    	if ((offset / 64 != off / 64) && buf != 0) {
    		len = pwrite(page_idle_fd, &buf, 8, 8 * (off / 64));
    		if (len < 0) {
    			perror("mark page idle");
    			return len;
    		}
    	}
    	buf = 1UL << (offset % 64);
    	off = offset;
    	return 0;
    }
    
    Also, it's not very clear what's going on here - the handling of
    offset, off and buf.  Some well-crafted comments would help.
    
    >
    > ...
    >
    


  reply	other threads:[~2018-07-05 18:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 15:32 Christian Hansen
2018-06-19 22:39 ` Andrew Morton
2018-07-05 18:14   ` Christian Hansen (chansen3) [this message]
2018-06-19 22:41 ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2018-07-06 17:22 Christian Hansen
2018-06-01 15:18 Christian 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=5F15F2EE-61F9-4E6F-99B2-B417B02C0F19@cisco.com \
    --to=chansen3@cisco.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xe-linux-external@cisco.com \
    /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

all inboxes | Powered by JetHome®