From: Minchan Kim <minchan@kernel.org>
To: Michal Hocko <mhocko@kernel.org>
Cc: "Huang, Ying" <ying.huang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Huang Ying <huang.ying.caritas@gmail.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
stable@vger.kernel.org, Christian Kujau <lists@nerdbynature.de>
Subject: Re: [PATCH -mm -V2] mm, swap: Fix false error message in __swp_swapcount()
Date: Tue, 31 Oct 2017 11:17:02 +0900 [thread overview]
Message-ID: <20171031021702.GA942@bbox> (raw)
In-Reply-To: <20171030080230.apijacsx7fd3qeox@dhcp22.suse.cz>
On Mon, Oct 30, 2017 at 09:02:30AM +0100, Michal Hocko wrote:
> On Mon 30-10-17 08:57:13, Minchan Kim wrote:
> [...]
> > Although it's better than old, we can make it simple, still.
> >
> > diff --git a/include/linux/swapops.h b/include/linux/swapops.h
> > index 291c4b534658..f50d5a48f03a 100644
> > --- a/include/linux/swapops.h
> > +++ b/include/linux/swapops.h
> > @@ -41,6 +41,13 @@ static inline unsigned swp_type(swp_entry_t entry)
> > return (entry.val >> SWP_TYPE_SHIFT(entry));
> > }
> >
> > +extern struct swap_info_struct *swap_info[];
> > +
> > +static inline struct swap_info_struct *swp_si(swp_entry_t entry)
> > +{
> > + return swap_info[swp_type(entry)];
> > +}
> > +
> > /*
> > * Extract the `offset' field from a swp_entry_t. The swp_entry_t is in
> > * arch-independent format
> > diff --git a/mm/swap_state.c b/mm/swap_state.c
> > index 378262d3a197..a0fe2d54ad09 100644
> > --- a/mm/swap_state.c
> > +++ b/mm/swap_state.c
> > @@ -554,6 +554,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
> > struct vm_area_struct *vma, unsigned long addr)
> > {
> > struct page *page;
> > + struct swap_info_struct *si = swp_si(entry);
>
> Aren't you accessing beyond the array here?
I couldn't understand what you intend. Could you explain what case does it accesses
beyond the arrary?
Thanks.
>
> > unsigned long entry_offset = swp_offset(entry);
> > unsigned long offset = entry_offset;
> > unsigned long start_offset, end_offset;
> > @@ -572,6 +573,9 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
> > if (!start_offset) /* First page is swap header. */
> > start_offset++;
> >
> > + if (end_offset >= si->max)
> > + end_offset = si->max - 1;
> > +
> > blk_start_plug(&plug);
> > for (offset = start_offset; offset <= end_offset ; offset++) {
> > /* Ok, do the async read-ahead now */
>
> --
> Michal Hocko
> SUSE Labs
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-10-31 2:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 5:53 Huang, Ying
2017-10-27 8:28 ` Michal Hocko
2017-10-29 23:57 ` Minchan Kim
2017-10-30 8:02 ` Michal Hocko
2017-10-31 2:17 ` Minchan Kim [this message]
2017-10-31 7:31 ` Michal Hocko
2017-10-31 7:37 ` Minchan Kim
2017-10-31 7:46 ` Michal Hocko
2017-10-31 5:32 ` Huang, Ying
2017-10-31 5:43 ` Minchan Kim
2017-10-31 5:46 ` Huang, Ying
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=20171031021702.GA942@bbox \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=huang.ying.caritas@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lists@nerdbynature.de \
--cc=mhocko@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tim.c.chen@linux.intel.com \
--cc=ying.huang@intel.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