Message ID | 20170911043820.14617-2-haozhong.zhang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, 2017-09-11 at 12:37 +0800, Haozhong Zhang wrote: > The current check refuses the hot-plugged memory that falls in one > unused PDX group, which should be allowed. Looks reasonable to me. The only thing I can think of is you can double check if the following find_next_zero_bit/find_next_bit will still work. Chao > > Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> > --- > Cc: Jan Beulich <jbeulich@suse.com> > Cc: Andrew Cooper <andrew.cooper3@citrix.com> > --- > xen/arch/x86/x86_64/mm.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c > index 11746730b4..6c5221f90c 100644 > --- a/xen/arch/x86/x86_64/mm.c > +++ b/xen/arch/x86/x86_64/mm.c > @@ -1296,12 +1296,8 @@ static int mem_hotadd_check(unsigned long spfn, > unsigned long epfn) > return 0; > > /* Make sure the new range is not present now */ > - sidx = ((pfn_to_pdx(spfn) + PDX_GROUP_COUNT - 1) & > ~(PDX_GROUP_COUNT - 1)) > - / PDX_GROUP_COUNT; > + sidx = (pfn_to_pdx(spfn) & ~(PDX_GROUP_COUNT - 1)) / > PDX_GROUP_COUNT; > eidx = (pfn_to_pdx(epfn - 1) & ~(PDX_GROUP_COUNT - 1)) / > PDX_GROUP_COUNT; > - if (sidx >= eidx) > - return 0; > - > s = find_next_zero_bit(pdx_group_valid, eidx, sidx); > if ( s > eidx ) > return 0;
On 10/27/17 14:49 +0800, Chao Peng wrote: > On Mon, 2017-09-11 at 12:37 +0800, Haozhong Zhang wrote: > > The current check refuses the hot-plugged memory that falls in one > > unused PDX group, which should be allowed. > > Looks reasonable to me. The only thing I can think of is you can double > check if the following find_next_zero_bit/find_next_bit will still > work. The first check in mem_hotadd_check() ensures spfn < epfn, so sidx <= eidx here. Compared with the previous code, the only added case is sidx == eidx, which is what this patch intends to allow and tested. Haozhong > > Chao > > > > Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> > > --- > > Cc: Jan Beulich <jbeulich@suse.com> > > Cc: Andrew Cooper <andrew.cooper3@citrix.com> > > --- > > xen/arch/x86/x86_64/mm.c | 6 +----- > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c > > index 11746730b4..6c5221f90c 100644 > > --- a/xen/arch/x86/x86_64/mm.c > > +++ b/xen/arch/x86/x86_64/mm.c > > @@ -1296,12 +1296,8 @@ static int mem_hotadd_check(unsigned long spfn, > > unsigned long epfn) > > return 0; > > > > /* Make sure the new range is not present now */ > > - sidx = ((pfn_to_pdx(spfn) + PDX_GROUP_COUNT - 1) & > > ~(PDX_GROUP_COUNT - 1)) > > - / PDX_GROUP_COUNT; > > + sidx = (pfn_to_pdx(spfn) & ~(PDX_GROUP_COUNT - 1)) / > > PDX_GROUP_COUNT; > > eidx = (pfn_to_pdx(epfn - 1) & ~(PDX_GROUP_COUNT - 1)) / > > PDX_GROUP_COUNT; > > - if (sidx >= eidx) > > - return 0; > > - > > s = find_next_zero_bit(pdx_group_valid, eidx, sidx); > > if ( s > eidx ) > > return 0;
diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 11746730b4..6c5221f90c 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -1296,12 +1296,8 @@ static int mem_hotadd_check(unsigned long spfn, unsigned long epfn) return 0; /* Make sure the new range is not present now */ - sidx = ((pfn_to_pdx(spfn) + PDX_GROUP_COUNT - 1) & ~(PDX_GROUP_COUNT - 1)) - / PDX_GROUP_COUNT; + sidx = (pfn_to_pdx(spfn) & ~(PDX_GROUP_COUNT - 1)) / PDX_GROUP_COUNT; eidx = (pfn_to_pdx(epfn - 1) & ~(PDX_GROUP_COUNT - 1)) / PDX_GROUP_COUNT; - if (sidx >= eidx) - return 0; - s = find_next_zero_bit(pdx_group_valid, eidx, sidx); if ( s > eidx ) return 0;
The current check refuses the hot-plugged memory that falls in one unused PDX group, which should be allowed. Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> --- Cc: Jan Beulich <jbeulich@suse.com> Cc: Andrew Cooper <andrew.cooper3@citrix.com> --- xen/arch/x86/x86_64/mm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)