summaryrefslogtreecommitdiffstats
path: root/net/batman-adv/hash.c
AgeCommit message (Expand)Author
2019-03-25batman-adv: Drop license boilerplateSven Eckelmann
2019-01-04batman-adv: Update copyright years for 2019Sven Eckelmann
2018-11-12batman-adv: Store modification counter via hash helpersSven Eckelmann
2018-02-26batman-adv: Update copyright years for 2018Sven Eckelmann
2017-12-15batman-adv: Add kernel-doc to externally visible functionsSven Eckelmann
2017-12-15batman-adv: include gfp.h for GFP_* definesSven Eckelmann
2017-12-15batman-adv: Add SPDX license identifier above copyright headerSven Eckelmann
2017-01-26batman-adv: update copyright years for 2017Sven Eckelmann
2016-02-02batman-adv: update copyright years for 2016Sven Eckelmann
2015-08-25batman-adv: Replace C99 int types with kernel typeSven Eckelmann
2015-06-07batman-adv: Add required includes to all filesSven Eckelmann
2015-05-29batman-adv: update copyright years for 2015Sven Eckelmann
2014-08-04batman-adv: prefer kmalloc_array to kmalloc when possibleAntonio Quartulli
2014-01-12batman-adv: update copyright years for 2014Simon Wunderlich
2014-01-08batman-adv: remove FSF address from GPL disclaimerAntonio Quartulli
2013-01-19batman-adv: update copyright yearsAntonio Quartulli
2012-07-01batman-adv: Remove space before semicolonSven Eckelmann
2012-07-01batman-adv: Prefix hash struct and typedef with batadv_Sven Eckelmann
2012-06-25batman-adv: Prefix hash local static functions with batadv_Sven Eckelmann
2012-06-20batman-adv: Reformat multiline comments to consistent styleSven Eckelmann
2012-06-20batman-adv: Prefix hash non-static functions with batadv_Sven Eckelmann
2012-06-18batman-adv: Initialize lockdep class keys for hashesSven Eckelmann
2012-02-17batman-adv: Update copyright yearsSven Eckelmann
2011-11-20batman-adv: fixed hash functions type to uint32_t instead of intAntonio Quartulli
2011-05-30batman-adv: Calculate sizeof using variable insead of typesSven Eckelmann
2011-03-05batman-adv: remove extra layer between hash and hash element - hash bucketMarek Lindner
2011-03-05batman-adv: protect each hash row with rcu locksMarek Lindner
2011-01-31batman-adv: Update copyright yearsSven Eckelmann
2010-12-16net: Add batman-adv meshing protocolSven Eckelmann
='#n235'>235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675
/*
 * kernel/lockdep_proc.c
 *
 * Runtime locking correctness validator
 *
 * Started by Ingo Molnar:
 *
 *  Copyright (C) 2006,2007 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
 *  Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
 *
 * Code for /proc/lockdep and /proc/lockdep_stats:
 *
 */
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/kallsyms.h>
#include <linux/debug_locks.h>
#include <linux/vmalloc.h>
#include <linux/sort.h>
#include <asm/uaccess.h>
#include <asm/div64.h>

#include "lockdep_internals.h"

static void *l_next(struct seq_file *m, void *v, loff_t *pos)
{
	struct lock_class *class;

	(*pos)++;

	if (v == SEQ_START_TOKEN)
		class = m->private;
	else {
		class = v;

		if (class->lock_entry.next != &all_lock_classes)
			class = list_entry(class->lock_entry.next,
					   struct lock_class, lock_entry);
		else
			class = NULL;
	}

	return class;
}

static void *l_start(struct seq_file *m, loff_t *pos)
{
	struct lock_class *class;
	loff_t i = 0;

	if (*pos == 0)
		return SEQ_START_TOKEN;

	list_for_each_entry(class, &all_lock_classes, lock_entry) {
		if (++i == *pos)
		return class;
	}
	return NULL;
}

static void l_stop(struct seq_file *m, void *v)
{
}

static unsigned long count_forward_deps(struct lock_class *class)
{
	struct lock_list *entry;
	unsigned long ret = 1;

	/*
	 * Recurse this class's dependency list:
	 */
	list_for_each_entry(entry, &class->locks_after, entry)
		ret += count_forward_deps(entry->class);

	return ret;
}

static unsigned long count_backward_deps(struct lock_class *class)
{
	struct lock_list *entry;
	unsigned long ret = 1;

	/*
	 * Recurse this class's dependency list:
	 */
	list_for_each_entry(entry, &class->locks_before, entry)
		ret += count_backward_deps(entry->class);

	return ret;
}

static void print_name(struct seq_file *m, struct lock_class *class)
{
	char str[128];
	const char *name = class->name;

	if (!name) {
		name = __get_key_name(class->key, str);
		seq_printf(m, "%s", name);
	} else{
		seq_printf(m, "%s", name);
		if (class->name_version > 1)
			seq_printf(m, "#%d", class->name_version);
		if (class->subclass)
			seq_printf(m, "/%d", class->subclass);
	}
}

static int l_show(struct seq_file *m, void *v)
{
	unsigned long nr_forward_deps, nr_backward_deps;
	struct lock_class *class = v;
	struct lock_list *entry;
	char c1, c2, c3, c4;

	if (v == SEQ_START_TOKEN) {
		seq_printf(m, "all lock classes:\n");
		return 0;
	}

	seq_printf(m, "%p", class->key);
#ifdef CONFIG_DEBUG_LOCKDEP
	seq_printf(m, " OPS:%8ld", class->ops);
#endif
	nr_forward_deps = count_forward_deps(class);
	seq_printf(m, " FD:%5ld", nr_forward_deps);

	nr_backward_deps = count_backward_deps(class);
	seq_printf(m, " BD:%5ld", nr_backward_deps);

	get_usage_chars(class, &c1, &c2, &c3, &c4);
	seq_printf(m, " %c%c%c%c", c1, c2, c3, c4);

	seq_printf(m, ": ");
	print_name(m, class);
	seq_puts(m, "\n");

	list_for_each_entry(entry, &class->locks_after, entry) {
		if (entry->distance == 1) {
			seq_printf(m, " -> [%p] ", entry->class);
			print_name(m, entry->class);
			seq_puts(m, "\n");
		}
	}
	seq_puts(m, "\n");

	return 0;
}

static const struct seq_operations lockdep_ops = {
	.start	= l_start,
	.next	= l_next,
	.stop	= l_stop,
	.show	= l_show,
};

static int lockdep_open(struct inode *inode, struct file *file)
{
	int res = seq_open(file, &lockdep_ops);
	if (!res) {
		struct seq_file *m = file->private_data;

		if (!list_empty(&all_lock_classes))
			m->private = list_entry(all_lock_classes.next,
					struct lock_class, lock_entry);
		else
			m->private = NULL;
	}
	return res;
}

static const struct file_operations proc_lockdep_operations = {
	.open		= lockdep_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= seq_release,
};

static void lockdep_stats_debug_show(struct seq_file *m)
{
#ifdef CONFIG_DEBUG_LOCKDEP
	unsigned int hi1 = debug_atomic_read(&hardirqs_on_events),
		     hi2 = debug_atomic_read(&hardirqs_off_events),
		     hr1 = debug_atomic_read(&redundant_hardirqs_on),
		     hr2 = debug_atomic_read(&redundant_hardirqs_off),
		     si1 = debug_atomic_read(&softirqs_on_events),
		     si2 = debug_atomic_read(&softirqs_off_events),
		     sr1 = debug_atomic_read(&redundant_softirqs_on),
		     sr2 = debug_atomic_read(&redundant_softirqs_off);

	seq_printf(m, " chain lookup misses:           %11u\n",
		debug_atomic_read(&chain_lookup_misses));
	seq_printf(m, " chain lookup hits:             %11u\n",
		debug_atomic_read(&chain_lookup_hits));
	seq_printf(m, " cyclic checks:                 %11u\n",
		debug_atomic_read(&nr_cyclic_checks));
	seq_printf(m, " cyclic-check recursions:       %11u\n",
		debug_atomic_read(&nr_cyclic_check_recursions));
	seq_printf(m, " find-mask forwards checks:     %11u\n",
		debug_atomic_read(&