Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

rootBusPath: create rootBusPath dynamically. #860

Merged
merged 1 commit into from
Nov 26, 2020

Conversation

jongwu
Copy link
Contributor

@jongwu jongwu commented Oct 26, 2020

Currently, rootBusPath is set as a constant value. Bus this pcie bus path
is not alway static, eg. the rootBus on arm64 is
"/devices/platform/4010000000.pcie/pci0000:00". The address part of
"4010000000.pcie" may vary with the maxMem in qemu so it should not be a
fixed value.

For exmaple:
HIGH PCIE address reserved in qemu on virt is from 0 to 512G. The lower
part of address may be allocated to normal memory. In general, normal memory
is largely less than 256G, so the base address of HIGH PCIE can be 256G.
But, in case the maxmem is large enough, like around 256G, the base address
of HIGH PCIE must be increase, eg. 300G.
In the current implementation of kata-runtime, the maxmem in qemu is the host
memory size. So if the host memory size is large enough, the prefix of the
pci device path name will be different from rootBusPath set in kata-agent which
can lead to failure on device hotplug.

This patch offer a mechanism to create rootBusPath dynamically but only give
implemention for arm64 and return the default value of rootBusPath for other arch.

Fixes: #859
Signed-off-by: Jianyong Wu jianyong.wu@arm.com

@jodh-intel @devimc

@codecov
Copy link

codecov bot commented Oct 26, 2020

Codecov Report

Merging #860 (d66fcb8) into master (5cfb8ec) will increase coverage by 0.08%.
The diff coverage is 60.00%.

@@            Coverage Diff             @@
##           master     #860      +/-   ##
==========================================
+ Coverage   57.72%   57.81%   +0.08%     
==========================================
  Files          17       19       +2     
  Lines        2370     2375       +5     
==========================================
+ Hits         1368     1373       +5     
  Misses        840      840              
  Partials      162      162              

@alicefr
Copy link

alicefr commented Oct 26, 2020

cc @jschintag

Copy link
Contributor

@dgibson dgibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea. ppc64 doesn't need this just yet, but at some point it will need the ability to handle multiple PCI roots, and this gets us a little closer to doing that.

@devimc
Copy link

devimc commented Oct 26, 2020

/test

Copy link

@devimc devimc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @jongwu

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jongwu - thanks for raising. I've added some comments so blocking PR for now...

device_arm64.go Outdated
fmt.Errorf("Error reading %s: %s", sysStartRootBusPath, err)
}

// find out the director end with ".pcie"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo ("directory" rather than "director")?

device_arm64.go Outdated

// find out the director end with ".pcie"
for _, file := range files {
if strings.HasSuffix(file.Name(), ".pcie") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the comment above has a typo, shouldn't this also test that file.IsDir() == true?

device_arm64.go Outdated
}
}

return ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does returning "" mean? Is that a valid scenario or should this function actually return (string, error)?

device_arm64.go Outdated
sysStartRootBusPath := filepath.Join(sysfsDir, startRootBusPath)
files, err := ioutil.ReadDir(sysStartRootBusPath)
if err != nil {
fmt.Errorf("Error reading %s: %s", sysStartRootBusPath, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggests the function should be returning an error to me...?

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jongwu.

lgtm

@jodh-intel
Copy link
Contributor

/test

@jodh-intel
Copy link
Contributor

@jongwu - Travis is failing - looks like you need to update the tests for the latest changes.

@jongwu
Copy link
Contributor Author

jongwu commented Oct 27, 2020

thanks @jodh-intel , I have fixed it. now could you please retrigger ci again?

@jodh-intel
Copy link
Contributor

/test

@jongwu
Copy link
Contributor Author

jongwu commented Oct 27, 2020

hello @jodh-intel -, I can't see ARM CI, could please trigger it?

@jodh-intel
Copy link
Contributor

/test-arm

@jongwu - I've added you to the runtime + agent repos so you should be able to trigger builds yourself from now on. Also, are you planning to port this to the new 2.0 rust agent?

@jodh-intel jodh-intel added the needs-forward-port Changes need to be applied to a newer branch / repository label Oct 27, 2020
@amshinde
Copy link
Member

/test-arm

@amshinde
Copy link
Member

Dont see an ARM CI.
@chavafg Is it not enabled for the agent?

@chavafg
Copy link
Contributor

chavafg commented Oct 27, 2020

hmm, yeah, it seems that arm CI has not been enabled for this repo. @jongwu could you help adding it? let me know if you need help.

@jongwu
Copy link
Contributor Author

jongwu commented Oct 28, 2020

/test-arm

@jongwu
Copy link
Contributor Author

jongwu commented Oct 28, 2020

/test

1 similar comment
@jongwu
Copy link
Contributor Author

jongwu commented Oct 28, 2020

/test

Currently, rootBusPath is set as a constant value. Bus this pcie bus path
is not alway static, eg. the rootBus on arm64 is
"/devices/platform/4010000000.pcie/pci0000:00". The address part of
"4010000000.pcie" may vary with the maxMem in qemu so it should not be a
fixed value.

For exmaple:
HIGH PCIE address reserved in qemu on virt is from 0 to 512G. The lower
part of address may be allocated to normal memory. In general, normal memory
is largely less than 256G, so the base address of HIGH PCIE can be 256G.
But, in case the maxmem is large enough, like around 256G, the base address
of HIGH PCIE must be increase, eg. 300G.
In the current implementation of kata-runtime, the maxmem in qemu is the host
memory size. So if the host memory size is large enough, the prefix of the
pci device path name will be different from rootBusPath set in kata-agent which
can lead to failure on device hotplug.

This patch offer a mechanism to create rootBusPath dynamically but only give
implemention for arm64 and return the default value of rootBusPath for other arch.

Fixes: kata-containers#859
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
@jongwu
Copy link
Contributor Author

jongwu commented Oct 28, 2020

/test

jongwu added a commit to jongwu/kata-containers that referenced this pull request Oct 30, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
@jongwu
Copy link
Contributor Author

jongwu commented Oct 30, 2020

Thanks @jodh-intel -, I have composed the rust version of this patch, see rust. It's not easy for me to write rust code.

@jodh-intel
Copy link
Contributor

Thanks @jongwu! No problem - we can help if necessary 😄

jongwu added a commit to jongwu/kata-containers that referenced this pull request Oct 30, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
@jongwu
Copy link
Contributor Author

jongwu commented Oct 30, 2020

thanks @jodh-intel .

jongwu added a commit to jongwu/kata-containers that referenced this pull request Nov 3, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
jongwu added a commit to jongwu/kata-containers that referenced this pull request Nov 3, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
jongwu added a commit to jongwu/kata-containers that referenced this pull request Nov 3, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
jongwu added a commit to jongwu/kata-containers that referenced this pull request Nov 4, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
jongwu added a commit to jongwu/kata-containers that referenced this pull request Nov 4, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
jongwu added a commit to jongwu/kata-containers that referenced this pull request Nov 5, 2020
port kata-containers/agent#860 here.

Fixes: kata-containers#1059
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
@jongwu
Copy link
Contributor Author

jongwu commented Nov 26, 2020

Hello @jodh-intel @chavafg, all tests pass. isn't time to merge this?

@devimc devimc merged commit 25d7471 into kata-containers:master Nov 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-forward-port Changes need to be applied to a newer branch / repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fail to hotplug device if host memory size large enough
7 participants