mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-05-03 19:12:16 +00:00
libs: Fix clippy needless_borrow
Fix `needless_borrow` clippy warning as suggested by rust 1.85.1, since
`mem-agent` is now a member of `libs` workspace.
```console
error: this expression creates a reference which is immediately dereferenced by the compiler
--> mem-agent/src/memcg.rs:1100:52
|
1100 | self.run_eviction_single_config(infov, &config)?;
| ^^^^^^^ help: change this to: `config`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
```
Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
@@ -574,7 +574,7 @@ impl MemCgroups {
|
||||
let need_insert = if update_cgroups {
|
||||
if let Some(mg) = self.cgroups.get_mut(path) {
|
||||
// Update current
|
||||
mg.update_from_hostmemcg(&hmg);
|
||||
mg.update_from_hostmemcg(hmg);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
@@ -594,7 +594,7 @@ impl MemCgroups {
|
||||
loop {
|
||||
if let Some(secs_config_map) = self.config_map.get_mut(&config.period_secs)
|
||||
{
|
||||
if let Some(config_map) = secs_config_map.cgs.get_mut(&config) {
|
||||
if let Some(config_map) = secs_config_map.cgs.get_mut(config) {
|
||||
if let Some(_) = config_map.get_mut(path) {
|
||||
error!(
|
||||
"update_and_add found an memcg {:?} {} existed",
|
||||
@@ -624,7 +624,7 @@ impl MemCgroups {
|
||||
);
|
||||
|
||||
cgroups.add_numa(
|
||||
&numa_id,
|
||||
numa_id,
|
||||
path,
|
||||
&self.config.psi_path,
|
||||
hmg,
|
||||
@@ -641,7 +641,7 @@ impl MemCgroups {
|
||||
id,
|
||||
ino,
|
||||
path,
|
||||
&numa_id,
|
||||
numa_id,
|
||||
hmg,
|
||||
&self.config.psi_path,
|
||||
),
|
||||
@@ -682,7 +682,7 @@ impl MemCgroups {
|
||||
for (path, numa_map) in path_map {
|
||||
if let Some(mcg) = self.cgroups.get_mut(path) {
|
||||
for numa_id in &numa_map.numa {
|
||||
if let Some(numa) = mcg.numa.get_mut(&numa_id) {
|
||||
if let Some(numa) = mcg.numa.get_mut(numa_id) {
|
||||
let pass = match numa
|
||||
.check_psi(single_config.period_psi_percent_limit as u64)
|
||||
{
|
||||
@@ -702,7 +702,7 @@ impl MemCgroups {
|
||||
}
|
||||
|
||||
info_ret.push(Info::new(
|
||||
&path,
|
||||
path,
|
||||
mcg.id as usize,
|
||||
*numa_id as usize,
|
||||
numa,
|
||||
@@ -1097,7 +1097,7 @@ impl MemCG {
|
||||
fn run_eviction(&mut self, config_infov: &mut [(SingleConfig, Vec<Info>)]) -> Result<()> {
|
||||
for (config, infov) in config_infov.iter_mut() {
|
||||
debug!("run_eviction_single_config {:?}", config);
|
||||
self.run_eviction_single_config(infov, &config)?;
|
||||
self.run_eviction_single_config(infov, config)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1312,7 +1312,7 @@ impl MemCG {
|
||||
}
|
||||
|
||||
let mut mgs = self.memcgs.blocking_write();
|
||||
mgs.record_eviction(&infov);
|
||||
mgs.record_eviction(infov);
|
||||
mgs.record_eviction(&removed_infov);
|
||||
|
||||
ret
|
||||
|
||||
@@ -140,9 +140,9 @@ fn lru_gen_seq_lines_parse(reader: &mut BufReader<File>) -> Result<(String, Opti
|
||||
|
||||
gen.seq = u64::from_str_radix(words[0], 10)
|
||||
.map_err(|e| anyhow!("parse line {} failed: {}", line, e))?;
|
||||
gen.anon = str_to_u64(&words[2 + WORKINGSET_ANON])
|
||||
gen.anon = str_to_u64(words[2 + WORKINGSET_ANON])
|
||||
.map_err(|e| anyhow!("parse line {} failed: {}", line, e))?;
|
||||
gen.file = str_to_u64(&words[2 + WORKINGSET_FILE])
|
||||
gen.file = str_to_u64(words[2 + WORKINGSET_FILE])
|
||||
.map_err(|e| anyhow!("parse line {} failed: {}", line, e))?;
|
||||
|
||||
if !got {
|
||||
@@ -174,7 +174,7 @@ fn lru_gen_seq_lines_parse(reader: &mut BufReader<File>) -> Result<(String, Opti
|
||||
//result:
|
||||
// HashMap<path, (id, HashMap<node_id, MGenLRU>)>
|
||||
fn lru_gen_file_parse(
|
||||
mut reader: &mut BufReader<File>,
|
||||
reader: &mut BufReader<File>,
|
||||
target_patchs: &HashSet<String>,
|
||||
parse_line: bool,
|
||||
) -> Result<HashMap<String, (usize, HashMap<usize, MGenLRU>)>> {
|
||||
@@ -191,7 +191,7 @@ fn lru_gen_file_parse(
|
||||
if let Ok((id, path)) = lru_gen_head_parse(&line) {
|
||||
if target_patchs.is_empty() || target_patchs.contains(&path) {
|
||||
let seq_data = if parse_line {
|
||||
let (ret_line, data) = lru_gen_lines_parse(&mut reader).map_err(|e| {
|
||||
let (ret_line, data) = lru_gen_lines_parse(reader).map_err(|e| {
|
||||
anyhow!(
|
||||
"lru_gen_seq_lines_parse file {} failed: {}",
|
||||
LRU_GEN_PATH,
|
||||
|
||||
Reference in New Issue
Block a user