Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm_mpam: Add a helper to touch an MSC from any CPU

Resetting RIS entries from the cpuhp callback is easy as the
callback occurs on the correct CPU. This won't be true for any other
caller that wants to reset or configure an MSC.

Add a helper that schedules the provided function if necessary.

Callers should take the cpuhp lock to prevent the cpuhp callbacks from
changing the MSC state.

Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Fenghua Yu <fenghuay@nvidia.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com>
Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

James Morse and committed by
Catalin Marinas
475228d1 f188a36c

+34 -3
+34 -3
drivers/resctrl/mpam_devices.c
··· 806 806 mutex_unlock(&msc->part_sel_lock); 807 807 } 808 808 809 - static void mpam_reset_ris(struct mpam_msc_ris *ris) 809 + /* 810 + * Called via smp_call_on_cpu() to prevent migration, while still being 811 + * pre-emptible. 812 + */ 813 + static int mpam_reset_ris(void *arg) 810 814 { 811 815 u16 partid, partid_max; 816 + struct mpam_msc_ris *ris = arg; 812 817 813 818 WARN_ON_ONCE(!srcu_read_lock_held((&mpam_srcu))); 814 819 815 820 if (ris->in_reset_state) 816 - return; 821 + return 0; 817 822 818 823 spin_lock(&partid_max_lock); 819 824 partid_max = mpam_partid_max; 820 825 spin_unlock(&partid_max_lock); 821 826 for (partid = 0; partid <= partid_max; partid++) 822 827 mpam_reset_ris_partid(ris, partid); 828 + 829 + return 0; 830 + } 831 + 832 + /* 833 + * Get the preferred CPU for this MSC. If it is accessible from this CPU, 834 + * this CPU is preferred. This can be preempted/migrated, it will only result 835 + * in more work. 836 + */ 837 + static int mpam_get_msc_preferred_cpu(struct mpam_msc *msc) 838 + { 839 + int cpu = raw_smp_processor_id(); 840 + 841 + if (cpumask_test_cpu(cpu, &msc->accessibility)) 842 + return cpu; 843 + 844 + return cpumask_first_and(&msc->accessibility, cpu_online_mask); 845 + } 846 + 847 + static int mpam_touch_msc(struct mpam_msc *msc, int (*fn)(void *a), void *arg) 848 + { 849 + lockdep_assert_irqs_enabled(); 850 + lockdep_assert_cpus_held(); 851 + WARN_ON_ONCE(!srcu_read_lock_held((&mpam_srcu))); 852 + 853 + return smp_call_on_cpu(mpam_get_msc_preferred_cpu(msc), fn, arg, true); 823 854 } 824 855 825 856 static void mpam_reset_msc(struct mpam_msc *msc, bool online) ··· 858 827 struct mpam_msc_ris *ris; 859 828 860 829 list_for_each_entry_srcu(ris, &msc->ris, msc_list, srcu_read_lock_held(&mpam_srcu)) { 861 - mpam_reset_ris(ris); 830 + mpam_touch_msc(msc, &mpam_reset_ris, ris); 862 831 863 832 /* 864 833 * Set in_reset_state when coming online. The reset state